我是 JS 的新手,我想知道为什么这段代码会打印错误。我究竟做错了什么?感谢您的任何提示!
var x = Object.create(Object.prototype, {x:{value:3, writable:true, enumerable:true}});
console.log(x.propertyIsEnumerable(x)); //false
最佳答案
好吧,你错过了引号:
x.propertyIsEnumerable('x')
见下文:
var x = Object.create(Object.prototype, {x:{value:3, writable:true, enumerable:true}});
console.log(x.propertyIsEnumerable('x'));
关于javascript - 为什么我不能在 Object.create() 中使用属性描述符设置可写属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45652070/