Last Updated : 12 Jul, 2025
JavaScript handler.isExtensible() method in JavaScript is a trap for Object.isExtensible() method and it returns a boolean value.
Syntax:
const p = new Proxy(target, { isExtensible: function(target) { } });
Parameters: This method accepts a single parameter as mentioned above and described below:
Return value: This method returns a Boolean value.
Below examples illustrate the handler.isExtensible() method in JavaScript:
Example 1: In this example, we will set a trap for the extensible property of the object using the handler.isExtensible() method in JavaScript.
javascript
const monster1 = {
canEvolve: true
};
const handler1 = {
isExtensible(target) {
return Reflect.isExtensible(target);
},
preventExtensions(target) {
target.canEvolve = false;
return Reflect.preventExtensions(target);
}
};
const proxy1 = new Proxy(monster1, handler1);
console.log(Object.isExtensible(proxy1));
console.log(monster1.canEvolve);
console.log(Object.preventExtensions(proxy1));
console.log(Object.isExtensible(proxy1));
console.log(monster1.canEvolve);
Output:
true true [object Object] false false
Example 2: In this example, we will set a trap for the extensible property of the object using the handler.isExtensible() method in JavaScript.
javascript
const p = new Proxy({}, {
isExtensible: function (target) {
console.log('isExtensible method');
return true;
}
});
console.log(Object.isExtensible(p));
let a = {
canEvolve: true
};
let b = {
isExtensible(target) {
return true;
},
};
const proxy1 = new Proxy(a, b);
console.log(Object.isExtensible(proxy1));
Output:
"isExtensible method" true true
Supported Browsers: The browsers supported by handler.isExtensible() method are listed below:
We have a complete list of Javascript Proxy/handler methods, to check those go through the Javascript Proxy/handler Reference article.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4