Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 94231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:28:08+00:00 2026-05-10T23:28:08+00:00

I’been doing some inheritance in js in order to understand it better, and I

  • 0

I’been doing some inheritance in js in order to understand it better, and I found something that confuses me.

I know that when you call an ‘constructor function’ with the new keyword, you get a new object with a reference to that function’s prototype.

I also know that in order to make prototypal inheritance you must replace the prototype of the constructor function with an instance of the object you want to be the ‘superclass’.

So I did this silly example to try these concepts:

function Animal(){} function Dog(){}  Animal.prototype.run = function(){alert('running...')};  Dog.prototype = new Animal();  Dog.prototype.bark = function(){alert('arf!')};  var fido = new Dog(); fido.bark() //ok fido.run() //ok  console.log(Dog.prototype) // its an 'Object'  console.log(fido.prototype) // UNDEFINED console.log(fido.constructor.prototype == Dog.prototype) //this is true  function KillerDog(){}; KillerDog.prototype.deathBite = function(){alert('AAARFFF! *bite*')}  fido.prototype = new KillerDog();  console.log(fido.prototype) // no longer UNDEFINED fido.deathBite(); // but this doesn't work! 

(This was done in Firebug’s console)

1) Why if all new objects contain a reference to the creator function’s prototype, fido.prototype is undefined?

2) Is the inheritance chain [obj] -> [constructor] -> [prototype] instead of [obj] -> [prototype] ?

3) is the ‘prototype’ property of our object (fido) ever checked? if so… why is ‘deathBite’ undefined (in the last part)?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:28:09+00:00Added an answer on May 10, 2026 at 11:28 pm

    1) Why if all new objects contain a reference to the creator function’s prototype, fido.prototype is undefined?

    All new objects do hold a reference to the prototype that was present on their constructor at the time of construction. However the property name used to store this reference is not prototype as it is on the constructor function itself. Some Javascript implementations do allow access to this ‘hidden’ property via some property name like __proto__ where others do not (for example Microsofts).

    2) Is the inheritance chain [obj] -> [constructor] -> [prototype] instead of [obj] -> [prototype] ?

    No. Take a look at this:-

    function Base() {} Base.prototype.doThis = function() { alert('First'); }  function Base2() {} Base2.prototype.doThis = function() { alert('Second'); }  function Derived() {} Derived.prototype = new Base()  var x = new Derived()  Derived.prototype = new Base2()  x.doThis(); 

    This alerts ‘First’ not Second. If the inheritance chain went via the constructor we would see ‘Second’. When an object is constructed the current reference held in the Functions prototype property is transfered to the object hidden reference to its prototype.

    3) is the ‘prototype’ property of our object (fido) ever checked? if so… why is ‘deathBite’ undefined (in the last part)?

    Assigning to an object (other than a Function) a property called prototype has no special meaning, as stated earlier an object does not maintain a reference to its prototype via such a property name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.