The static method Reflect.isExtensible serves the purpose of determining whether an object can be extended. This method functions similarly to Object.isExtensible, though with some distinctions.
Syntax:
Example
Reflect.isExtensible(obj)
Parameters:
Obj: This refers to the object in question that is being evaluated for its extensibility.
Return value:
This function yields a Boolean value that signifies whether the target can be extended or not.
Exceptions:
A TypeError, if the target is not an Object.
Browser Support:
| Chrome | 49 |
|---|---|
Edge |
12 |
| Firefox | 42 |
| Opera | 36 |
Example 1
Example
const object = {};
console.log(Reflect.isExtensible(object));
Reflect.preventExtensions(object);
console.log(Reflect.isExtensible(object));
Output:
Output
true
false
Example 2
Example
const object2 = Object.seal({});
console.log(Reflect.isExtensible(object2));
const object3 = Object.seal({});
console.log(Reflect.isExtensible(object3));
Output:
Output
false
false
Example 3
Example
const object = {};
const object1 = {};
console.log(Reflect.isExtensible(object1));
Reflect.preventExtensions(object);
console.log(Reflect.isExtensible(object));
Output:
Output
true
false