Name
Object.seal() — prevent the addition or deletion of properties
Availability
ECMAScript 5
Synopsis
Object.seal(o)
Arguments
oThe object to be sealed
Returns
The now-sealed argument object
o.
Description
Object.seal() makes
o non-extensible (see Object.preventExtensions()) and makes all of its own
properties non-configurable. This has the effect of preventing the
addition of new properties and preventing the deletion of existing
properties. Sealing an object is permanent: once sealed, an object
cannot be unsealed.
Note that Object.seal()
does not make properties read-only; see Object.freeze() for that. Also note that Object.seal() does not affect inherited
properties. If a sealed object has a non-sealed object in its
prototype chain, then inherited properties may be added or
removed.
Note that this is not a method to be invoked on an object: it is a global function and you must pass an object to it.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access