About prototype and prototype chain are learning in a knowledge JS not avoid, this knowledge has a lot of information here do not explain anything, about the prototype, we should know that there quest:
- Constructor
prototype
inside the properties and methods can be invoked directly by the object instance - Properties and methods defined in the constructor, the time when the object is instantiated, the instance of the object properties and methods are present in its own space, if a plurality of objects, attributes and methods which are present in a separate space waste of memory space, so, for data sharing, should be shared property or method written in the prototype object, in order to achieve data sharing, to achieve the purpose of saving memory.
- One prototype is the role of data sharing, to save memory space, the second is to inherit
- Instance object looks and constructors are directly related, but in fact is an indirect relationship, and prototype instance object is an object constructor
prototype
has a direct relationship, and object constructor prototype constructor points (this will achieve through inheritance) - The final point of the prototype chain is null
To help understand the prototype chain, by way of illustration is the most intuitive, here from the Internet to find a map, coupled with his understanding, this figure seems to be drawing in a book, which book I specifically I do not know, I did not read, borrow here.