handler.isExtensible()

handler.isExtensible() 메서드는 Object.isExtensible()에 대한 트랩입니다.

시도해보기

구문

new Proxy(target, {
  isExtensible(target) {
  }
});

매개 변수

다음 매개변수는 isExtensible() 메서드에 전달됩니다. this는 처리기에 바인딩됩니다.

target

대상 객체

반환 값

isExtensible() 메서드는 불리언 값을 반환합니다.

설명

handler.isExtensible() 메서드는 Object.isExtensible()에 대한 트랩입니다.

가로채기

이 트랩은 다음 작업을 가로챌 수 있습니다.

불변 조건

다음 불변 조건이 위반되면 프록시에서 TypeError가 발생합니다.

  • Object.isExtensible(proxy)는 반드시 Object.isExtensible(target)와 같은 값을 반환해야합니다.

예제

isExtensible 트랩

다음 코드는 Object.isExtensible()를 트랩합니다.

const p = new Proxy({}, {
  isExtensible(target) {
    console.log('called');
    return true;
  }
});

console.log(Object.isExtensible(p)); // "called"
                                     // true

다음 코드는 불변 조건을 위반합니다.

const p = new Proxy({}, {
  isExtensible(target) {
    return false;
  }
});

Object.isExtensible(p); // TypeError is thrown

명세서

Specification
ECMAScript Language Specification
# sec-proxy-object-internal-methods-and-internal-slots-isextensible

브라우저 호환성

BCD tables only load in the browser

같이 보기