The Reflect.isExtensible(object) method

The Reflect.isExtensible() method is used to check if an object is extensible or not,--that is, if we can add new properties to an object.

An object can be marked as non-extensible using the Object.preventExtensions(), Object.freeze(), and the Object.seal() methods.

The Reflect.isExtensible() method is the same as the Object.isExtensible() method.

Here is a code example that demonstrates how to use the Reflect.isExtensible() method:

var obj = { name: "Eden" }; console.log(Reflect.isExtensible(obj)); //Output "true" Object.preventExtensions(obj); console.log(Reflect.isExtensible(obj)); //Output "false"

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.