Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2016년 9월.
handler.set() 메서드는 속성 값을 설정을 위한 트랩입니다.
다음 매개변수는 set() 메서드에 전달됩니다. this는 처리기에 바인딩됩니다.
target대상 객체
property설정할 속성의 이름 또는 Symbol
value설정할 속성의 새 값
receiver할당이 지시된 원래 객체입니다. 이것은 일반적으로 프록시 자체입니다. 그러나 set() 처리기는 프로토타입 체인이나 다양한 다른 방법 등을 통해 간접적으로 호출할 수도 있습니다.
예를 들어, 스크립트가 obj.name = "jen"을 수행하는데, obj는 프록시가 아니면서 속성 .name이 없고, 프로토타입 체인에는 프록시가 있다고 가정해봅시다. 이떄 해당 프록시의 set() 처리기가 호출되고나서 obj가 수신자로 전달됩니다.
set() 메서드는 불리언 값을 반환합니다.
handler.set() 메서드는 속성 값을 설정을 위한 트랩입니다.
이 트랩은 다음 작업을 가로챌 수 있습니다.
다음 불변 조건이 위반되면 프록시에서 TypeError가 발생합니다.
다음 코드는 속성 값을 설정하는 것을 트랩합니다.
| ECMAScript® 2027 Language Specification # sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 6월 24일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.