1、get / set
var test = { _Name: "Limei", _Age: 20, get name() { return this._Name;}, set age(age) {this._Age = age;}, get age() { return this._Age;} } alert(test.name + "" + test.age);//Limei 20 test.name = "Lily"; test.age = 18; alert(test.name + "" + test.age);//Limei 18 alert(test._Name + "" + test._Age);//Limei 18
get只读 set设置键值 ,当只有get这个函数只读,只有set这个函数只写,同时拥有两个则为可读可写,上述例子age便是可读可写的,name为只读