JS: Object.isExtensible

JS: Object.isExtensible


Return true if a object obj is an object and is extensible, else false.

[see JS: What's Object?]

Extensible means properties can be added.

[see JS: Prevent Adding Property]

// check if a object is extensible

console.log( Object.isExtensible( {} )); // true
// return false for non object
console.log( Object.isExtensible( 3 )); // false


If using ES2015, use Reflect.isExtensible instead. It throws error if argument is not object.

[see JS: Reflect.isExtensible]


ECMAScript® 2016 Language Specification#sec-object.isextensible

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon