JS prototype chain illustrated in

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:

  1. Constructor prototypeinside the properties and methods can be invoked directly by the object instance
  2. 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.
  3. One prototype is the role of data sharing, to save memory space, the second is to inherit
  4. Instance object looks and constructors are directly related, but in fact is an indirect relationship, and prototype instance object is an object constructor prototypehas a direct relationship, and object constructor prototype constructor points (this will achieve through inheritance)
  5. 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.
Here Insert Picture Description

Published 28 original articles · won praise 1 · views 8733

Guess you like

Origin blog.csdn.net/moqiuqin/article/details/94648865