isExtensible() - JavaScript Tutorial

isExtensible()

BLUF: This tutorial on isExtensible() provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: isExtensible()

Understanding isExtensible() is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

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

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience