Object.isFrozen
Checks whether an object is frozen.
Available since: ES5
Syntax
Object.isFrozen(obj)Parameters
| Parameter | Type | Description |
|---|---|---|
| obj | object | The 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
trueNotes
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.