When accessing a property or method in an instance, it is looked up from the object of the instance and, if it does not exist, in the prototype.
So: If there is a property in the prototype, the override in the instance object hides the property access of the prototype.
functionPerson () {}person.prototype.name= "Jack"; Person.prototype.sayName=function() {alert ( This. name);}varP1 =NewPerson (); Alert (P1.hasownproperty ("Name"));//False The hasOwnProperty method is to determine if this property exists in the instanceAlert ("Name"inchp1);//The true in operator is to determine whether this property exists in the instance and the prototypeP1.name= "Tom"; alert (p1.name)//Tom hides the properties of the prototypeDeleteP1.name;alert (p1.name);//Jack
But if you rewrite prototype, you'll break the original search method.
Like what:
Person.prototype = { "Jack", function () { alert (this . name);} } var New //
This will be an error, because the prototype chain is broken, the search is not the prototype of the Sayname method.
Prototype Property method Access