JS in the prototype, __ proto__ and constructor

 

We need to keep in mind two things:

①__proto__ and the object constructor property is unique;

② prototype property is a unique function, because function is also an object, so also has the function __proto__ and constructor property.
__proto__ role attribute is that when accessing properties of an object, if the object is inside this property does not exist, then it will go to that object __proto__ attribute points (parent) where to find, been looking until _ end null _proto__ property, then return undefined, and then further on to find the equivalent in the null value, will complain. The object is connected via this link __proto__ property that is what we call the prototype chain.


Role is to make the prototype property of function objects instantiated who can find common properties and methods that f1 .__ proto__ === Foo.prototype.


Meaning constructor property is directed to the object constructor function, all functions (in this case as the subject) constructor final point Function.

 

reference:

https://blog.csdn.net/cc18868876837/article/details/81211729

Guess you like

Origin www.cnblogs.com/sea-stream/p/11204541.html