var book={};
Object.defineProperties(book,{
_year:{
value:2004
},
edition:{
value:1
},
year:{
get:function () {
return this._year;
// body...
},
set:function(newValue){
if (newValue>2004) {
this._year=newValue;
this.edition+=newValue-2004;
}
}
}
});
book.year=2005;
console.log(book.year);![图片描述][1]
欢迎选择我的课程,让我们一起见证您的进步~~