JavaScript 对象的 DontDelete 属性
根据 EcmaScript 规范,由于 DontDelete 内部参数,某些对象属性无法删除。例如:
var y = 5
不应被删除。但据我所知——确实如此。
这是 Mozilla 开发者中心的链接: https://developer.mozilla.org/en/JavaScript/Reference/Operators /Special/delete
有什么想法为什么这不能正常工作吗?
According to EcmaScript specification some objects properties cannot be deleted due to the DontDelete internal parameter. For example :
var y = 5
should not be deletable. But from what I was able to check - it is.
Here's a link at Mozilla Developer Center :
https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special/delete
Any ideas why this isn't working as it should ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有时你必须检查你所读的内容。 ECMA 规范(262,第 5 版)中没有 DontDelete 内部参数。也许 [
Configurable
] 属性是什么意思?delete
运算符不适用于变量或函数,它适用于对象属性:从我的回答来看,这个 SO 问题出现了,TJ Crowder 给出了很好的答案。
Sometimes you have to check what you read. There is no
DontDelete
internal parameter in the ECMA-specification (262, ed 5). Maybe the [Configurable
] property is meant? Thedelete
operator doesn't work on variables or functions, it works on object properties:From my answer, this SO question emerged, and an excellent answer from T.J. Crowder.
根据 ES5 表 17:
以及 10.5 声明绑定实例化
这对我来说声明的变量不应该是可删除的。在全局代码中,全局对象是激活对象,即变量 obejct,因此声明的全局变量不应被删除。当然,浏览器可能不遵守这一点......
According to ES5 table 17:
and in 10.5 Declaration Binding Instantiation
Which says to me that declared variables should be not deleteable. In global code, the global object is the activation object which is the variable obejct, so declared globals shouldn't be deletable. Of course, browsers may not adhere to that...
显示false。那么就无法删除了。
Show false. Then, can't be deleted.