function People(name) { this.name=name; This.introduce =function(){alert("My name is "+this.name); Function (){alert("I can Run "); } / People/prototype method. The prototype. IntroduceChinese = function () {alert (" my name is "+ enclosing name); } var p1=new People("Windking"); p1.Introduce(); // The object method calls people.run () by instantiating the object; P1.introducechinese (); // Class methods don't need to invoke p1.introducechinese () by instantiating the object. // Prototype methods are also called by instantiating objectsCopy the code

conclusion

Object methods include methods in constructors and methods above constructor prototypes; 2, class method, in fact, the class here is a function, in JS function is also an object, so you can add attributes and methods for the function, this method is more used in Node; SayName =function(){console.log(this.name); person.prototype. sayName=function(){console.log(this.name); }; By adding this method to the prototype, you can share it. This eliminates the need to allocate memory each time an instance is initialized.