admin管理员组文章数量:1026989
In Javascript strict mode
Deleting an undeletable property is not allowed
To make sure that one do not delete such an undeletable property, how do one figure out property X is deletable and property Y is undeletable
The concept behind it is......?
In Javascript strict mode
Deleting an undeletable property is not allowed
To make sure that one do not delete such an undeletable property, how do one figure out property X is deletable and property Y is undeletable
The concept behind it is......?
Share Improve this question asked Dec 18, 2015 at 14:24 Mr.XMr.X 31.4k27 gold badges147 silver badges229 bronze badges1 Answer
Reset to default 11The concept behind this is...?
Property attributes. Every property that has its configurable
attribute set to false
cannot be delete
d (which fails silently in sloppy mode and throws in strict mode).
How to figure out whether a property is deletable?
You can use the Object.getOwnPropertyDescriptor()
function to access the attributes as an object:
var isDeletable = Object.getOwnPropertyDescriptor(obj, "propName").configurable;
Notice that this will only work for own properties of obj
, not inherited ones; for those you will have to call the function on the respective prototype.
In Javascript strict mode
Deleting an undeletable property is not allowed
To make sure that one do not delete such an undeletable property, how do one figure out property X is deletable and property Y is undeletable
The concept behind it is......?
In Javascript strict mode
Deleting an undeletable property is not allowed
To make sure that one do not delete such an undeletable property, how do one figure out property X is deletable and property Y is undeletable
The concept behind it is......?
Share Improve this question asked Dec 18, 2015 at 14:24 Mr.XMr.X 31.4k27 gold badges147 silver badges229 bronze badges1 Answer
Reset to default 11The concept behind this is...?
Property attributes. Every property that has its configurable
attribute set to false
cannot be delete
d (which fails silently in sloppy mode and throws in strict mode).
How to figure out whether a property is deletable?
You can use the Object.getOwnPropertyDescriptor()
function to access the attributes as an object:
var isDeletable = Object.getOwnPropertyDescriptor(obj, "propName").configurable;
Notice that this will only work for own properties of obj
, not inherited ones; for those you will have to call the function on the respective prototype.
本文标签: How to identify javascript undeletable propertiesStack Overflow
版权声明:本文标题:How to identify javascript undeletable properties? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745660139a2161839.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论