var person = { usename : "wade", _age : "18", get age (){ return this._age; }, set age(val){ if(val < 0 || val > 100){ throw new Error("年龄不合实际"); }else{ return this._age; } } }; console.log(person.age);