Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Object.isFrozen — checking whether an object is frozen

Object.isFrozen(value) checks whether an object is non-extensible, its own properties are non-configurable, and its data properties are also non-writable. It neither freezes the object nor recursively checks nested objects.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

Object.isFrozen(value)

Object.isFrozen(value) is a static method that returns true when an object cannot gain own properties, all its own properties have configurable: false, and its own data properties additionally have writable: false. Symbol keys and non-enumerable properties are included, but inherited properties are not.

The method inspects state rather than changing it; use Object.freeze to freeze an object. Object.seal alone is insufficient if writable data properties remain. However, an empty object becomes frozen after Object.preventExtensions, because it has no properties that violate the remaining conditions.

A true result does not imply deep immutability. Objects stored as property values can still change. Accessor properties may retain setters, and getters may return changing results; the test does not require removing them or invoke an ordinary object's getters.

For primitive values, including null and undefined, the current specification returns true. With a Proxy, inspection can trigger traps and throw an exception, so it is not always a side-effect-free operation.

Examples

const settings = { theme: { dark: false } };
console.log(Object.isFrozen(settings));
Object.freeze(settings);
console.log(Object.isFrozen(settings));
console.log(Object.isFrozen(settings.theme));
settings.theme.dark = true;
console.log(settings.theme.dark);
console.log(Object.isFrozen(Object.preventExtensions({})));
console.log(Object.isFrozen(null));

Result

false
true
false
true
true
true

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources