Reflect.isExtensible()

The static Reflect.isExtensible() method determines if an object is extensible (whether it can have new properties added to it). It is similar to Object.isExtensible(), but with some differences.

Try it

Syntax

Reflect.isExtensible(target)

Parameters

target

The target object which to check if it is extensible.

Return value

A Boolean indicating whether or not the target is extensible.

Exceptions

A TypeError, if target is not an Object.

Examples

Using Reflect.isExtensible()

See also Object.isExtensible().

// New objects are extensible.
const empty = {};
Reflect.isExtensible(empty); // true

// ...but that can be changed.
Reflect.preventExtensions(empty);
Reflect.isExtensible(empty); // false

// Sealed objects are by definition non-extensible.
const sealed = Object.seal({});
Reflect.isExtensible(sealed); // false

// Frozen objects are also by definition non-extensible.
const frozen = Object.freeze({});
Reflect.isExtensible(frozen); // false

Difference with Object.isExtensible()

If the target argument to this method is not an object (a primitive), then it will cause a TypeError. With Object.isExtensible(), a non-object target will return false without any errors.

Reflect.isExtensible(1);
// TypeError: 1 is not an object

Object.isExtensible(1);
// false

Specifications

Specification
ECMAScript Language Specification
# sec-reflect.isextensible

Browser compatibility

BCD tables only load in the browser

See also