Object.seal()

Seals an object, preventing new properties and making existing ones non-configurable.

Since ES5 Spec ↗

Syntax

Object.seal(obj)

Parameters

NameTypeRequiredDescription
obj object Yes The object to seal.

Returns

object — The same object, now sealed.

Examples

const o = Object.seal({ a: 1 });
o.a = 2;       // allowed
o.b = 3;       // ignored
console.log(o);
Output
{ a: 2 }
console.log(Object.isSealed(Object.seal({})));
Output
true

Notes

Unlike `freeze`, existing writable properties can still be reassigned; you just cannot add or delete properties or reconfigure them. Shallow operation.

Browser & runtime support

EnvironmentSince version
chrome 6
firefox 4
safari 5.1
edge 12
node 0.10

See also