Tell us what’s happening:
I’m used to programming in Java so I find the prototype concept painful to grasp
he
hasOwnPropertymethod is defined inObject.prototype, which can be accessed byBird.prototype, which can then be accessed byduck. This is an example of theprototypechain.In this
prototypechain,Birdis thesupertypeforduck, whileduckis thesubtype.Objectis asupertypefor bothBirdandduck.
function Bird(name) {
this.name = name;
}
typeof Bird.prototype; // => object
let duck= new Bird("ducky");
Bird.prototype.isPrototypeOf(duck); // => true
the question is:
how the constructor function(Birds) can access the Object.prototype on the same way that objects access(duck)!
Object.prototype.isPrototypeOf(Bird.prototype);//true
Brid.prototype.isPrototypeOf(duck.prototype);//true
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.
Link to the challenge:
I can’t include links yet sorry!
//https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-prototype-chain/