Home > front end >  Why destroy the constructor's prototype, instance objects can also inherit this function attrib
Why destroy the constructor's prototype, instance objects can also inherit this function attrib

Time:04-05

 
The function Dog (name) {
this.name=name;
}
Let dogA=new Dog (" Paul ");

T prototype. Eat=true;
DogA. Eat;//true, obtain the constructor eat attribute

T prototype=null;//will be the prototype of the constructor instead of null
DogA. Eat;//true,,, how instance objects and eat?


According to truth is not a constructor's prototype gone, turns to be null, how do dogA the instance objects can also obtain the eat=true?
  • Related