Name

Object.isSealed() — can properties be added to or deleted from an object?

Availability

ECMAScript 5

Synopsis

Object.isSealed(o)

Arguments

o

The object to be checked

Returns

true if o is sealed, or false if it is not.

Description

An object is sealed if no new (non-inherited) properties can be added to it and no existing (non-inherited) properties can be deleted from it. Object.isSealed() tests whether its argument is sealed or not. Once sealed, an object can never be unsealed. The usual way to seal an object is by passing it to Object.seal() or Object.freeze(). It is also possible to seal an object by passing it to Object.preventExtensions() and then using Object.defineProperty() to make all of its properties non-deleteable.

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.