The article introduces you to an example of Javascript's static methods and prototype methods. If you don't understand Javascript's static methods and prototype methods, you can take a look with the editor. A piece of code to understand static methods and instance methods:
<script> //Object constructor function Atest(name){ //Private attributes can only be used inside object constructor var className = "Atest"; //Public attributes, called after object instantiation = name; //Object method = function(){ alert(); alert(());//The method used to expand the prototype method can be used inside the class alert();//Properties expanded using prototype methods can be used inside the class alert();//The format of static attributes is [Object.static attributes] } } //Class method (actually a static method is called directly) Location: External of Person class Syntax format: class name. Method name = function([parameter...]){ statement line; } = function(){ alert("I am a class method Run"); } //Prototype method = function(){ alert("My name is:"+);//If the prototype method is called directly as a static method, it cannot be called } //Public static properties outside the class = 20;//Public static attributes cannot be used [this.properties], only [Object.properties] call //Prototype attributes are used as attributes inside the class [this.prototype attributes], or as public static attributes [object.prototype.prototype attributes] = "male"; (); //The class method is also a static method, and you can use [Object.static method()] ();//When a prototype method is used as a static method [Object.prototype.Method()] alert();//When used as a static property [Object.prototype.Method()] var a = new Atest("zhangsan");//Object methods and prototype methods need to be instantiated before they can be used ();//Object method must instantiate the object ();//The prototype method must instantiate the object alert()://Error, public static attributes can only be called using [Object.Properties] //ps: Try to define the method as a prototype method. The prototype method avoids the construction of attributes or methods every time the constructor is called, saving space and creating objects quickly. </script>