Prototype can have a lot of optimized implementation methods
http://blog.csdn.net/liuqiwen0512/article/details/8089690
In JavaScript, each function object has a default property of prototype, called the prototype member of the function object, which points to an object, called the prototype object of the function, and when each of us defines a function, JavaScript creates a corresponding prototype object. In other words, when we define a function, we actually get two objects, a function object, a prototype object. The prototype object is a special object, and the prototype member of the function points to its prototype object.
A reference to this prototype object can be obtained through the prototype member of the function object.
The following defines a function object person and then obtains its prototype object through prototype. A method is then defined on its prototype object.
function person () {} Person.prototype.showPerson = function () { alert (' Person Object. ');} var alice = new Person (); Ali Ce.showperson ();
The members defined on this prototype object will be used for sharing with all objects created through this function. Equivalent to instance methods in C #, objects, functions, and prototypes in-memory relationships as shown in
The ingenious use of prototype in "jquery" JavaScript to create objects using the prototype property prototype chain