function Person(obj){
if(!(this instanceof Person)){
return new Person(obj);//构造器中使用 new 是一种 "反模式"
}
this.name = obj.name;
this.age = obj.age;
this.address = obj.address;
this.nice = obj.nice;
}
console.time('11');
var person = new Person({name:'lxq',age:'23',address:'huizhou',nice:'nice'});
console.timeEnd('11');
console.log(person);
//使用 json 数据传参
var json = {
"name": "Giulio",
"age": "123",
"address": "address",
"nice": "nice",
}
var person2 = new Person(json);
console.log(person2);