Prototype and Object Orientation in JS

Prototype and object-oriented in JS

//Turn a method into an object, create methods and properties for the object

var Name = function () {

//Create a method for an object through prototype

Name.prototype.Add = function (num, title ) {

}
//You can also directly use this to add the method name to the object creation method and the above equivalent

this.Way = function (str) {

}

//Add property value to the object

Name.prototype.xing = "123";

/ /Methods can also declare

function Name1() {

Name1.prototype.add = function () { }

this.way = function () { }

/*Static global variables, which can be called outside the method; static local variables and methods Only for use within methods; instance objects

cannot call static methods*/

/*Instance objects cannot use prototype; */

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326615755&siteId=291194637