定义多个属性 Object.defineProperties()
var book = {} Object.defineProperties(book,{ _year:{ value:2004 }, editable:{ value:1 }, year:{ get:function(){ return this._year }, set:function(newYear){ if(newYear > 2004){ this._year = newYear; this.editable += newYear - 2004; } } }})
// _year数据属性,year访问器属性
posted on 2017-07-03 13:38 CNundefined 阅读(165) 评论(0) 编辑 收藏 举报