Home  >  Article  >  Web Front-end  >  Javascript study notes 6 Proposal of prototype_Basic knowledge

Javascript study notes 6 Proposal of prototype_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:36:45799browse

First, let’s continue the code above. Let’s extend this code:

Copy the code The code is as follows:




The result is false. That is, the methods of these two objects are different methods. Then we know that in C#, each object maintains a method table, but the method table should point to the same address. If this is the case, then when we declare 100 objects, do we have to create 100 object copies? Is this a big waste of space?

So we thought of this solution, using prototype:
Copy the code The code is as follows: