创建对象构造器
//例子
function person(firstname,lastname,age,eyecolor){
this.firstname=firstname;
this.lastname=lastname;
this.age=age;
this.eyecolor=eyecolor;
//在构造器函数内部定义对象的方法:
this.changeName=changeName;
function changeName(name){
this.firstname=name;
}
}
//一旦您有了对象构造器,就可以创建新的对象实例,就像这样:
var myFather=new person("John","Doe",50,"blue");
var myMother=new person("Sally","Rally",48,"green");
//修改firstname值
person.changeName("dog")