Name
Object.isFrozen() — is an object immutable?
Availability
ECMAScript 5
Synopsis
Object.isFrozen(o)
Arguments
oThe object to be checked
Returns
true if
o is frozen and immutable, or false if it is not.
Description
An object is frozen if all of its non-inherited properties
(except those with setter methods) are read-only, and if it is
sealed. An object is sealed if no new (non-inherited) properties can
be added to it, no existing (non-inherited) properties can be
deleted from it. Object.isFrozen() tests whether its
argument is frozen or not. Once frozen, an object can never be
unfrozen.
The usual way to freeze an object is by passing it to Object.freeze(). It is also possible to freeze an object by passing it to Object.preventExtensions() and then using Object.defineProperty() to make all of its properties read-only and nondeletable.
Note that this is not a method to be invoked on an object: it is a global function and you must pass an object to it.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access