function Stundent(name, age, id) {
this.name = name;
this.age = age;
this.id = id;
if (typeof this.setName != "function") {
Stundent.prototype.setName = function (newName) {
this.name = newName;
}
Stundent.prototype.getName = function () {
alert(this.name)
return this.name;
}
}
}
var s1 = new Stundent("张三", 21, 1001);
s1.setName("李四")
s1.getName();