Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Object.isFrozen

Checks whether an object is frozen.

Available since: ES5

Syntax

Object.isFrozen(obj)

Parameters

ParameterTypeDescription
objobjectThe object to check.

Return value

booleantrue if the object is frozen.

Examples

Before and after freezing:

const point = { x: 1 };
 
console.log(Object.isFrozen(point));
Object.freeze(point);
console.log(Object.isFrozen(point));

Output:

false
true

Notes

For sealed objects there is a similar check, Object.isSealed().

See also

  • Object.freeze — Prevents any changes to an object.
  • Object.seal — Forbids adding and removing properties but lets existing ones change.

In the tutorial

  • Immutability — Mutable and immutable data in JavaScript: object references, copying with spread, the toSorted and with methods, Object.freeze and structuredClone.

Thanks for reading!

Donate to the site — we work hard for you.