the understanding of prototypes; When we create a function, each function automatically generates a prototype (prototype) attribute, and this property is a pointer to an object, called a prototype object, in the function. The prototype object contains a constructor attribute, which can be referred back to the function when we add an attribute to the function, it is actually added to the prototype object, and when we create a new instance with the Neo operator, the new instance is the one that can share the properties in the prototype object. When we create a new instance, there is a prototype attribute in this instance, similar to the function, which is also a pointer to the prototype object of the function, but unlike the function, the instance can be added directly to the property, and the property in the function is added to the prototype object . The properties in the prototype object cannot be changed by overriding the properties in the instance, and when a new attribute is added to the instance, the new property is added to the instance without being added to the prototype object, and the property in the instance overrides the property when it is added to the instance with the same properties as the prototype object. Without changing the properties in the prototype object
JS Basic content Prototype and example