Name
Object.isExtensible() — can new properties be added to an object?
Availability
ECMAScript 5
Synopsis
Object
.
isExtensible
(
o
)
Arguments
o
The object to be checked for extensibility
Returns
true
if the object can be
extended with new properties, or false
if it cannot.
Description
An object is extensible (or extendable) if it can have new properties added to it. All objects are extendable when they are created and remain that way unless they are passed to Object.preventExtensions(), Object.seal(), or Object.freeze().
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.
Example
var
o
=
{};
// Start with a newly-created object
Object
.
isExtensible
(
o
)
// => true: it is extendable
Object
.
preventExtensions
(
o
);
// Make it non-extendable
Object
.
isExtensible
(
o
)
// => false: now it is not extendable
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.