var person = {};Object.defineProperty(person,"name",{ configurable:false, value:"Aaron"});高程第三版里面:此时,再调用Object.defineProperty()方法修改除writable之外的特性,都会导致错误但是我修改了writable,结果报错,如下:var person = {};Object.defineProperty(person,"name",{ configurable:false, value:"Aaron"});Object.defineProperty(person,"name",{ writable:true});//Uncaught TypeError: Cannot redefine property: name请问书上是不是有问题,还是我理解错了?我的理解:上面的例子中,通过Object.defineProperty()定义name属性,[[writable]]的是值是false,再调用一次Object.defineProperty()方法修改[[writable]]的值为true,所以报错,这样的吧?
添加回答
举报
0/150
提交
取消