protection

Object.isSealed

Returns true if the object is sealed — non-extensible and all own properties are non-configurable. Frozen objects are always sealed; primitives are considered sealed.

Object.isSealed(obj)

Parameters

Parameter Purpose
obj The value to test
returns Boolean — true if sealed

Examples

console.log(Object.isSealed({}));

Logs false

console.log(Object.isSealed(Object.seal({ a: 1 })));

Logs true

console.log(Object.isSealed(Object.freeze({ a: 1 })));

Logs true — every frozen object is also sealed

console.log(Object.isSealed('hello'));

Logs true — primitives are trivially sealed

Gotcha

A sealed object may still be writable — check with isFrozen if you also need immutability of values. Empty non-extensible objects are automatically sealed.

Related methods

← All JS Object methods · Array methods · Spread vs rest