Constructor prototype in js

The meaning of prototype is to provide a common area for instance objects to store public methods and public properties

Constructor prototype

The constructor instantiates an object
. When the object is instantiated, the object will create a prototype, namely object.prototype, which is equivalent to a father, and the instantiated object will have a __proto__, which is equivalent to a pointer, used to tell the object its father , That is, point to the new object created by object.prototype, object, and give this new object a __proto__ to point to its father. The constructor in this prototype points to object (constructor provides information about the construction method and can generate an instance) __proto__ cannot be traversed, because this is equivalent to a private property.

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49549509/article/details/108037718