The 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.