function Person(){
this.name = "zhangSan";
this.sex = "男";
this.age = 88;
}
Person.prototype={
getSex():function(){ //这一行提示缺少:
return this.sex;
},
getAge():function(){
return this.age;
}
};
var obj = new Person();
document.write(obj.getSex());
document.write(obj.getAge());
</script>
3 个解决方案
#1
Person.prototype={
getSex ():function(){ //这一行提示缺少:
return this.sex;
},
getAge ():function(){
return this.age;
}
};
括号去掉
getSex ():function(){ //这一行提示缺少:
return this.sex;
},
getAge ():function(){
return this.age;
}
};
括号去掉
#2
Person.prototype={
getSex:function(){
return this.sex;
},
getAge:function(){
return this.age;
}
};
#3
还真是,谢谢了,呵呵
#1
Person.prototype={
getSex ():function(){ //这一行提示缺少:
return this.sex;
},
getAge ():function(){
return this.age;
}
};
括号去掉
getSex ():function(){ //这一行提示缺少:
return this.sex;
},
getAge ():function(){
return this.age;
}
};
括号去掉
#2
Person.prototype={
getSex:function(){
return this.sex;
},
getAge:function(){
return this.age;
}
};
#3
还真是,谢谢了,呵呵