| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Meta_programming | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
Proxy .
,
const handler = {
get(target, name) {
return name in target ? target[name] : 42;
},
};
const p = new Proxy({}, handler);
p.a = 1;
console.log(p.a, p.b); // 1, 42
Proxy target( ) get handler . undefined 42 .
Proxy .
.
.
. ( '' .)
. . ( ) target .
'' . TypeError .
ProxyProxy.revocable() Proxy . revoke .
const revocable = Proxy.revocable(
{},
{
get(target, name) {
return `[[${name}]]`;
},
},
);
const proxy = revocable.proxy;
console.log(proxy.foo); // "[[foo]]"
revocable.revoke();
console.log(proxy.foo); // TypeError: 'get'
proxy.foo = 1; // TypeError: 'set'
delete proxy.foo; // TypeError: 'deleteProperty'
console.log(typeof proxy); // "object", typeof
Reflect . .
Reflect .
Reflect target .
, Reflect.has() in :
Reflect.has(Object, "assign"); // true
Reflect , this ( ) arguments Function.prototype.apply() .
Function.prototype.apply.call(Math.floor, undefined, [1.75]);
Reflect.apply(Math.floor, undefined, [1.75]);
// 1
Reflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111]);
// "hello"
Reflect.apply(RegExp.prototype.exec, /ab/, ["confabulation"]).index;
// 4
Reflect.apply("".charAt, "ponies", [3]);
// "i"
Object.defineProperty , TypeError . try...catch . , Reflect.defineProperty() , if...else :
if (Reflect.defineProperty(target, property, attributes)) {
//
} else {
//
}
This page was last modified on 2026 7 15 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |