function Person(){
var age=0;//定义私有成员变量age
function checkAge(age){
if(age<0 && age>150){
return false;
}
return true;
}
this.setAge=function(theAge){
if(checkAge(theAge)){
age=theAge;
}else{
alert("please input cuerrent age!");
}
}
this.getAge=function(){
document.write(age);
return age;
}
}
var per=new Person();
per.setAge(122);
per.getAge();