Dear Campers,
I have been reading about prototypes and prototype chain in Javascript. I have come to understand that if i create a constructor Person()
;
function Person(){
this.name = "Nibble"
this.age = 100
}
There is a Person.prototype
property which is created and the value of this property is an object, which object has constructor
property whose value is the constructor itself and then if i create an instance of the Person
object, like me = new Person()
, and the new Person
i have created inherits from the Person.prototype
object.
Similarly the constructor is a function and functions are objects as well. If you create Person()
which is a function object, does it have a constructor? If yes, what is the constructor of the constructor? Is it Object()
constructor? and does the constructor of the consatructor have a prototype object too? Where does the chain stop. Somebody kindly clear this up for me.