Home > Article > Web Front-end > What is the prototype chain of js?
Each constructor has a prototype object. The prototype object contains a pointer to the constructor, and the instance contains a pointer to the inside of the prototype object. We make the instance of the prototype object (1) equal to another prototype object (2). At this time, the prototype object (2) will contain a pointer to the prototype object (1), and then let the instance of the prototype object (2) equal the prototype object ( 3). Such layer-by-layer progression forms a chain of instances and prototypes. This is the concept of prototype chain.
In other words, each constructor has a prototype object, and each constructor instance contains an internal pointer (proto) pointing to the prototype object. If we let the The prototype object of one constructor is equal to the instance of the second constructor. As a result, the prototype object of the first constructor will contain a pointer to the second prototype object, and then the third prototype object is equal to the first constructor. instance, so that the third prototype object will also contain a pointer to the first prototype object, and so on, it is enough to form a chain of instances in the prototype. This is the basic concept of the prototype chain.
The above is the detailed content of What is the prototype chain of js?. For more information, please follow other related articles on the PHP Chinese website!