Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | Reflect.isExtensible() Method

  • Last Updated : 30 Sep, 2021

The Reflect.isExtensible() method in JavaScript is used to check whether an object is extensible or not. This method is similar to Object.isExtensible() but it will cause a TypeError if target is not an object.
Syntax: 
 

Reflect.isExtensible( obj )

Parameters: This method accepts single parameter as mentioned above and described below: 
 

  • Obj: This parameter is the target object and is used to check whether it is extensible.

Return value: This method returns a Boolean value which indicates if the target is extensible.
Exceptions: A TypeError is exception given as the result, when the target is not Object.
Below examples illustrate the Reflect.isExtensible() method in JavaScript:
Example 1: 
 

javascript




<script>
const object1 = {};
 
console.log(Reflect.isExtensible(object1));
Reflect.preventExtensions(object1); 
console.log(Reflect.isExtensible(object1));
 
const object2 = Object.seal({}); 
console.log(Reflect.isExtensible(object2)); 
   
const object3 = Object.seal({}); 
console.log(Reflect.isExtensible(object3));
</script>

Output: 
 

true
false
false
false

Example 2: 
 

javascript




<script>
 
// Sealed objects are by definition
// non-extensible.
let sealed = Object.seal({}) 
console.log(Reflect.isExtensible(sealed));
 
let empty = {}
console.log(Reflect.isExtensible(empty));
 
// ...but that can be changed.
Reflect.preventExtensions(empty) 
console.log(Reflect.isExtensible(empty));
 
// Frozen objects are also by
// definition non-extensible.
let frozen = Object.freeze({}) 
console.log(Reflect.isExtensible(frozen));
</script>

Output: 
 

false
true
false
false

Supported Browsers: The browsers supported by JavaScript Reflect.construct() Method are listed below: 
 

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

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!