A diagram of the prototype
-
The key to understanding stereotypes is the relationship between the stereotypes of constructor objects,
-
First, for instance zhangsan, the direct relationship between the prototype and the constructor is implemented by __proto__, and can also be shown by the prototype.isPrototype method to determine the relationship between the object and the constructor prototype
-
The constructor stereotype has a constructor attribute, which connects the relationship between the stereotype of the constructor and the constructor itself
-
The constructor itself is also an object, so it has a __proto__ attribute pointing to function. prototype, so all functions can call the Functioin. Prototype methods, such as bind, etc
-
All functions are prototyped as objects, and all are constructed by the Object constructor
-
Function itself is also an object, with __proto__ pointing to function.prototype
-
A prototype chain is a prototype of an object as an instance of another function, which is then connected to each other to form a prototype chain
For other prototype understanding, see another article juejin.cn/post/696201…