Prototype and proto what is it all about?
I came across this picture:
The picture shows that we have some kind of function(I understand the constructor, here I would also like some explanation). It has 2 properties that lead to Foo. prototype and Function.prototype. The question is difficult to formulate, because I do not understand what these 2 different prototypes are. Can you chew?
1
1 answers
A function is an object, and all objects have a hidden property, the value of which is the prototype object on which it was created.
For functions, such a prototype is the object Function.prototype
.
Also, each function has a property .prototype
.
If you use a function as a constructor (call with the new
operator), the value of this property will be used as a prototype for the object being created.
4
Author: Grundy, 2020-08-08 08:58:24