/******************************-①工厂模式-******************************/
function createObj() {
let obj= new Object();
obj.name= "lle";
obj.age= 11;
return obj;
}
let oneObj = createObj();
/******************************-②构造函数-******************************/
function CreateObj(name, age) {
this.name= name;
this.age= age;
}
let oneObj = new CreateObj("lle", 11);
/******************************-③原型模式-******************************/
function CreateObj() {};
CreateObj.prototype= {
name: "lle",
age: 11
};
let oneObj = new CreateObj();
网友评论