请问这段代码有什么问题,console.log出来的为什么是1,为什么不是3?
Object.defineProperties(book,{
_year:{
value:2004,
writable:true
},
edition:{
value:1,
writable:true
},
year:{
get:function(){
return this._year;
},
set:function(newValue){
if(newValue > 2004){
this._year = newValue;
this.edition += newValue - 2004;
}
}
}
})
13 回答12.8k 阅读
7 回答1.9k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答873 阅读✓ 已解决
6 回答1k 阅读
2 回答1.3k 阅读✓ 已解决
defineProperties如果不显式指定变量的属性描述符为true,那么这些属性
enumerable、configurable、writable
属性默认都是false,即不可枚举,不可删除,不可修改
。