[英]the delete operator in javascript
I would like to ask questions about 'delete' operator in Javascript我想问关于 Javascript 中的“删除”运算符的问题
Why为什么
delete window.document; // returns false
but但
delete navigator.geolocation; // returns true
I try other properties of navigator
and it still returns true
我尝试了
navigator
的其他属性,它仍然返回true
I have checked the IDL in webkit, document
and navigator
are both of readonly,我检查了 webkit 中的 IDL,
document
和navigator
器都是只读的,
and they dont have DontDelete attribute but why I can delete one but not for the other???他们没有 DontDelete 属性,但为什么我可以删除一个但不能删除另一个?
If you'd like to understand the delete
operator, wrap your mind around the javascript spec section 11.4.1如果您想了解
delete
运算符,请围绕javascript 规范部分 11.4.1
There are several cases where the operator should evaluate to true
without mutating any objects.在几种情况下,操作员应该在不改变任何对象的情况下评估为
true
。
From 8.12.7, the operator checks checks an internal [[Configurable]]
property of the property descriptor to enforce readonly properties.从 8.12.7 开始,操作员检查检查属性描述符的内部
[[Configurable]]
属性以强制执行只读属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.