Name
Object.seal() — prevent the addition or deletion of properties
Availability
ECMAScript 5
Synopsis
Object
.
seal
(
o
)
Arguments
o
The 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.
Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.