The handler.isExtensible function serves as a trap for the Object.isExtensible method. This functionality is typically utilized for purposes such as logging or monitoring invocations of Object.isExtensible, which is used to ascertain whether an object is "extensible."
Syntax
Example
isExtensible: function(target)
Parameters
target : The target object.
Return value
Return a Boolean value.
Browser Support
| Chrome | Compatibility unknown |
|---|---|
Edge |
Compatibility unknown |
| Firefox | 31 |
| Opera | Compatibility unknown |
Example 1
Example
var x = { foo: 1 };
var proxy = new Proxy(x, {
isExtensible: function(target) {
document.writeln('in isExtensible');
//expected output: in isExtensible
return Object.isExtensible(target);
}
});
document.writeln(Object.isExtensible(proxy));
//expected output: true
document.writeln("<br/>")
Object.preventExtensions(proxy);
document.writeln(Object.isExtensible(proxy));
//expected output: false
Example
in isExtensible true
in isExtensible false
Example 2
Example
const pro={
too:1 }
const proxy = new Proxy(pro, {
isExtensible: function(target) {
document.writeln(' in value : ');
return true;
}
});
document.writeln(Object.isExtensible(proxy));
//expected output: in value : true
Output:
Output
in value : true
Example 3
Example
var a = {
canEvolve: true
};
var b = {
isExtensible(target) {
return true;
},
};
const proxy1 = new Proxy(a, b);
document.writeln(Object.isExtensible(proxy1));
// expected output: true
Output: