/**
* 人类
* @author rubekid
*/
function Person(options){
//私有属性
var _name; //姓名
var _age; //年龄
/**
* 构造函数
*/
var _construct = function(){
_name = options.name||"";
_age = options.age||0;
console.log("construct");
}();
this.getName = function(){
return _name;
};
this.setName = function(name){
_name = name;
};
this.getAge = function(){
return _age;
};
this.setAge = function(age){
_age = age;
};
}
//测试代码
var p = new Person({
name:"rubekid",
age:1
});
console.log(p.getAge());
p.setAge(4);
console.log(p.getAge());