get set 方法
1 var man = { 2 "name": "liushuanhua", 3 get age() { 4 return (new Date()).getFullYear() - 1991 5 }, 6 set age(val) { 7 console.log("you can\'t be set to " + val) 8 } 9 } 10 console.log(man.age) // 25 11 man.age = 1000; // you can't be set to 1000 12 console.log(man.age) // 25