1. Prototype rules
A. All reference types (arrays, objects, functions) have object attributes and are free to extend properties;
var arr = [];
ARR.A = 1;
B. All reference types (arrays, objects, functions) have a _proto_ attribute (implicit prototype), and the property value is an ordinary object;
C. All functions have a prototype (explicit prototype), and the attribute value is also a common object;
D. All reference types (arrays, objects, functions) whose implicit prototypes point to explicit prototypes of their constructors; (obj._proto_ = = = Object.prototype);
E. When trying to get a property of an object, if the object itself does not have this property, then it will go to its _proto_ (that is, its constructor of the prototype) to find;
2. Looping the properties of the object itself
When traversing an object's properties, the hasOwnProperty () method is used to determine whether a property is the property of an object itself; modern browsers have shielded the properties from the prototype in the for-in, but for the robustness of the program it is recommended to add this judgment:
for inch obj) { if(Obj.hasownproperty (item)) { alert (item) }}
3. Prototype chain
When trying to get a property of an object F, if the object itself does not have this property, it will go to its _proto_ (that is, its constructor prototype) Obj._proto_ to find, and when Obj._proto is not, it will be obj._proto. _proto_ (i.e., the constructor of the prototype of Obj's constructor is prototype);
The prototype rule and the prototype chain in JS