The JavaScript Reflect.isExtensible() method determines if an object is extensible or not. It is similar to Object.isExtensible().
Syntax:
Reflect.isExtensible(obj)
Parameters:
target: It represents the object which to check if it is extensible.
Return: It returns true if the object is extensible otherwise returns false.
Note: It throws TypeError, if the target is not an Object.
Reflect.isExtensible() VS Object.isExtensible()
Reflect.isExtensible(31); // It throws TypeError: 31 is not an object Object.isExtensible(31); // It returns false
Example 1:
<!DOCTYPE html>
<html>
<body>
<script>
const obj = {prop:100};
document.write(Reflect.isExtensible(obj));
</script>
</body>
</html>
Example 2:
<!DOCTYPE html>
<html>
<body>
<script>
const object1 = {};
document.write(Reflect.isExtensible(object1));
document.write("</br>");
Reflect.preventExtensions(object1);
document.write(Reflect.isExtensible(object1));
document.write("</br>");
const object2 = Object.seal({});
document.write(Reflect.isExtensible(object2));
</script>
</body>
</html>