Skip to content
Related Articles

Related Articles

Improve Article

JavaScript | handler.isExtensible() Method

  • Last Updated : 28 Sep, 2021

The 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 accept single parameter as mentioned above and described below: 
 

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • target: This parameter is the target object.

Return value: This method returns a Boolean value.
Below examples illustrate the handler.isExtensible() method in JavaScript:
Example 1: 
 

javascript




<script>
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);
document.writeln(Object.isExtensible(proxy1));
document.writeln("<br>");
document.writeln(monster1.canEvolve);
document.writeln("<br>");
document.writeln(Object.preventExtensions(proxy1));
document.writeln("<br>");
document.writeln(Object.isExtensible(proxy1));
document.writeln("<br>");
document.writeln(monster1.canEvolve); 
</script>

Output: 
 



true
true
[object Object]
false
false

Example 2: 
 

javascript




<script>
const p = new Proxy({}, {
  isExtensible: function(target) {
    console.log('isExtensible method');
    return true;
  }
});
 
console.log(Object.isExtensible(p));
 
var a = { 
  canEvolve: true 
}; 
var b = {  
  isExtensible(target) { 
    return true
  }, 
   }; 
const proxy1 = new Proxy(a, b); 
console.log(Object.isExtensible(proxy1));
</script>

Output: 
 

"isExtensible method"
true
true

Supported Browsers: The browsers supported by handler.isExtensible() method are listed below: 
 

  • Google Chrome 49 and above
  • Edge 12 and above
  • Firefox 31 and above
  • Opera 36 and above
  • Safari 10 and above

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :