ES6-06: Constructor prototype object prototype

Problems with the constructor

  • Waste of memory

Constructor prototype object prototype

  • The prototype object prototype of the constructor is shared by all instance objects.
  • Every constructor has a prototype property.
  • The properties and methods of the prototype will be owned by the constructor.
  • If the properties and methods that the instance doesn't have, you can go to the prototype object of its constructor to find them.

What is the significance of the existence of prototype objects?

Answer: The sharing method saves memory.

Guess you like

Origin blog.csdn.net/sinat_41696687/article/details/113845480