Simple understanding and illustration of prototypes and prototype chains

1. Prototype is an object;
2. Prototype is just a property of a function, not a prototype. Every object has a prototype, but not every object has a prototype attribute;
3. Every object has a __proto__ attribute, which points to the prototype attribute of the object’s constructor;
4. An object’s The prototype is the prototype of his constructor, that is, __proto__;
5. Every object has a __proto__, and __proto__ also has its own __proto__, which points to it layer by layer until __proto__ is null. That is, the prototype itself has prototypes, and this chain relationship is also the prototype chain. Because null is already the last point, the end of the prototype chain is null.
__proto__ and prototype relationship diagram

Guess you like

Origin blog.csdn.net/m0_38038767/article/details/108263860