Reputation: 1536
Imagine simple function:
function Person();
I know that Person
has __proto__
property that references to Function.prototype.
I also know that Person
has prototype
property. When I write:
function Person() {}
, a new prototype object is automatically created:
Person.prototype = { constructor: Person };
but inside Person.prototype block, I also have __proto__
, so what is this __proto__
, when is it created, who creates it?
I may know that it's Object
's prototype but is it always so?
Upvotes: 0
Views: 63
Reputation: 70
I'm not sure if I understand what you mean, but prototypes have their prototypes which can have their prototypes which can have their prototypes and so on until null
. Based on your question you may know it's called prototype chain, if not now you know :) You can read in more detail about it on Mozilla docs.
Upvotes: 1