<! DOCTYPE html>functionPerson () {}<!--Instance Object P1 (ex-child), at this time with a prototype object Person.prototype (former husband)-varP1 =NewPerson (); <!--P1 (ex-husband) is an example of a person--P1 on the prototype chain of Person.prototype (ex-husband)--Console.log (P1instanceofperson);//true<!--constructs a new Person.prototype (current husband), changing the (wife) person's prototype object (Person.prototype) to point to-Person.prototype={Constructor:person, say:function() {Console.log (' Shuohau '); } } <!--Create a current child p2-->varP2 =NewPerson (); <!--Results-<!--(ex-child p1) is not on the prototype chain of person (wife) and current husband (Person.prototype)--Console.log (P1instanceofperson);//false<!--(former child p1) on the prototype chain of person (wife) and current husband (Person.prototype)--Console.log (P2instanceofperson);//true</script></body>
JavaScript Tutorial Series 49:javascript Tutorial: The prototype chain is immutable