Home  >  Article  >  Web Front-end  >  What is the prototype chain of js?

What is the prototype chain of js?

藏色散人
藏色散人Original
2019-05-17 13:57:1511067browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is js framework?Next article:What is js framework?