Reflect.isExtensible()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

静的な Reflect.isExtensible() メソッドは 、オブジェクトを拡張できるかを測定します (オブジェクトに追加された新しいプロパティを持てるかどうか)。これは Object.isExtensible() に似ていますが、いくつかの違いがあります

試してみましょう

const object1 = {};

console.log(Reflect.isExtensible(object1));
// Expected output: true

Reflect.preventExtensions(object1);

console.log(Reflect.isExtensible(object1));
// Expected output: false

const object2 = Object.seal({});

console.log(Reflect.isExtensible(object2));
// Expected output: false

構文

Reflect.isExtensible(target)

引数

target

拡張できるかどうかをチェックする対象のオブジェクト。

返値

対象が拡張可能かどうかを示す Boolean 値。

例外

TypeError: targetObject ではなかった場合。

解説

Reflect.isExtensible メソッドは 、オブジェクトを拡張できるかを測定します(オブジェクトに追加された新しいプロパティを持てるかどうか)。これは Object.isExtensible() と同じメソッドです。

Reflect.isExtensible() の使用

Object.isExtensible() も見てください。

js
// 今オブジェクトは拡張可能。
let empty = {};
Reflect.isExtensible(empty); // === true

// ...しかし、変更できます
Reflect.preventExtensions(empty);
Reflect.isExtensible(empty); // === false

// シールドオブジェクトは拡張できないように定義される。
let sealed = Object.seal({});
Reflect.isExtensible(sealed); // === false

// フローズンオブジェクトも拡張できないように定義される。
let frozen = Object.freeze({});
Reflect.isExtensible(frozen); // === false

Object.isExtensible() との違い

このメソッドへの最初の引数がオブジェクトではなかった (プリミティブであった) 場合、これは TypeError を引き起こします。Object.isExtensible() だと、オブジェクトではない最初の引数はオブジェクトに強制的に変換されます。

js
Reflect.isExtensible(1);
// TypeError: 1 はオブジェクトではない

Object.isExtensible(1);
// false

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-reflect.isextensible

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
isExtensible

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報