javascript prototype

In javascript, there is prototype for all function(Class). prototype could be a property or function. All the instance of the function(Class) inherit the property.

There is one thing we need to pay attention, that  is the storage of the prototype

if instance modify prototype

  then instance has a special one in it's memory

else

  then instance share the prototype with all other instances

when instance wants to use prototype, at first it will check if it has special prototype(means it modified the prototype before), if yes, then use the special one. If no, use the shared one. 

原文地址:https://www.cnblogs.com/kevinge/p/1772009.html