请问这段代码有什么问题,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;
}
}
}
})
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答877 阅读✓ 已解决
3 回答1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
defineProperties如果不显式指定变量的属性描述符为true,那么这些属性
enumerable、configurable、writable
属性默认都是false,即不可枚举,不可删除,不可修改
。