You have a certain understanding of JavaScript. you are no stranger to jquery. You must have seen prototype when you look at jQuery source code, if you have any questions about prototype or want to learn more about it, you are welcome to continue reading it.
The original usage was to avoid repeated copies of random data in the constructor from being instantiated and later used in "inheritance". Note that JS semantics is not inherited, this is a human implementation. For the following titles in JavaScript, such as "object", "function", "type", and "method", I think it is important to understand them.
Each type in Javascript has the prototype attribute. In Javascript, the prototype attribute is interpreted as returning a reference to the prototype.
The function we write is also a type, and the object also has an attribute. prototype is the function attribute, which is also an object. The difference is that when a function is defined as a class, the process of creating a class instance (the new process) should refer to its prototype object and copy all properties of the prototype object to the new object. Therefore, we can see that prototype is a template, this template already exists before a new object. If you do not understand this section, let's continue to look at the example.
Please go to my personal website for further readingAddress: http://www.zingson.com/zing/157.html
You are welcome to share your resources on our website!