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 โจ2016๋ 9์โฉ.
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
.
์์ธ
์ค๋ช
Reflect.isExtensible()
๋ฉ์๋๋ Object.isExtensible()
์ ์ ์ฌํ๊ฒ, ๊ฐ์ฒด์ ์๋ก์ด ์์ฑ์ ์ถ๊ฐํ ์ ์๋์ง ํ๋ณํฉ๋๋ค.
์์
Reflect.isExtensible()
์ฌ์ฉํ๊ธฐ
Object.isExtensible()
๋ ์ฐธ๊ณ ํ์ธ์.
// ์๋ก์ด ๊ฐ์ฒด๋ ํ์ฅ ๊ฐ๋ฅ
var empty = {};
Reflect.isExtensible(empty); // === true
// ...ํ์ง๋ง ๋ฐ๊ฟ ์ ์์
Reflect.preventExtensions(empty);
Reflect.isExtensible(empty); // === false
// ๋ด์ธํ ๊ฐ์ฒด๋ ํ์ฅ ๋ถ๊ฐ๋ฅํจ
var sealed = Object.seal({});
Reflect.isExtensible(sealed); // === false
// ๋๊ฒฐํ ๊ฐ์ฒด๋ ํ์ฅ ๋ถ๊ฐ๋ฅํจ
var frozen = Object.freeze({});
Reflect.isExtensible(frozen); // === false
Object.isExtensible()
๊ณผ์ ์ฐจ์ด์
Reflect.isExtensible()
์ ์ฒซ ๋ฒ์งธ ๋งค๊ฐ๋ณ์๊ฐ ์์๊ฐ์ด๋ฉด TypeError
๋ฅผ ๋์ง๋๋ค. ๋ฐ๋ฉด Object.isExtensible()
์ ์ฐ์ ๊ฐ์ฒด๋ก ๋ณํ์ ์๋ํฉ๋๋ค.
Reflect.isExtensible(1);
// TypeError: 1 is not an object
Object.isExtensible(1);
// false
๋ช ์ธ
Specification |
---|
ECMAScriptยฎ 2026 Language Specification # sec-reflect.isextensible |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ