educative.io

Educative

Prototype Chain

I am don’t understand new shape object element(obj.[[Prototype]].[[Prototype]]) in Prototype Chain
where does it come from?

@Bedobadr

A prototype in JavaScript is an object from which another object is derived from. In class based languages we have a class which contains all the properties and methods defined inside the class. When the object of the class is created the newly created object has the access to the properties and the public methods defined inside the class.

Prototype is very similar to the class which acts as the blueprint of the JavaScript objects. The newly created JavaScript object has access to all the properties and methods of the prototype from which the object is created in addition to its own properties and methods.

Here this means that when we create an object of Shape we can derive an object which can derive an object and get all the properties from the inherited class in the first derived object from the last derived class object.

1 Like