JavaScript: Object.isFrozen
Object.isFrozen(obj)
-
Return
true
if it is impossible to {add, delete, change} properties.
Technically, when all of the following is true:
- If the object's “extensible” attribute is
false
. (cannot add properties) - If ALL of the object's own property's “configurable” attributes is
false
. (cannot delete properties) - If ALL of the object's own property's “writable” attributes is
false
. (cannot change property values)
[see Prevent Adding Property]
[see Object.freeze]
const x3 = {}; console.log(Object.isFrozen(x3)); // false Object.freeze(x3); console.log(Object.isFrozen(x3)); // true