Every object in JavaScript has a prototype property.
Object methods, class methods, prototype methods
1, Object method: Understanding is very simple, mainly if the class generates an instance, then the instance can use this method
2. Class method: A method that does not need to be used to generate an instance
3, the prototype method: mainly used to expand the JS existing system objects, such as array array there is no method, you can add a prototype method, then the created array has the method.
respective advantages
1, the object method: Includes the method in the constructor function and the constructor function prototype above method;
2, class method: In fact, the class is a function, in JS because the function is also an object, so you can add properties and methods for the function, this method in node with more;
3, prototype method: Commonly used for object instance sharing, such as Person.prototype.sayname=function () {console.log (this.name);}; By adding this method to the prototype, the share can be realized. This makes it necessary to allocate the appropriate memory for each instance when it is initialized.
JavaScript's prototype (prototype)