function Person(){
}
var p = new Person();
p.age = 23;
p.name = "zhangsan";
p.setName = function(name){
this.name = name;
}
document.write(p.name+"");
document.write(p.age+"");
p.setName("李四"); document.write(p.name+"");
function Student (name,age){
this.name = name;
this.age = age;
this.setName = function(name){
this.name = name;
}
this.getName = function(name){
return this.name;
}
}
var s = new Student("dubo",24);
document.write(s.getName());
网友评论