| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/get | [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.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2016 9.
handler.get() .
const monster1 = {
secret: "easily scared",
eyeCount: 4,
};
const handler1 = {
get: function (target, prop, receiver) {
if (prop === "secret") {
return `${target.secret.substring(0, 4)} ... shhhh!`;
}
return Reflect.get(...arguments);
},
};
const proxy1 = new Proxy(monster1, handler1);
console.log(proxy1.eyeCount);
// Expected output: 4
console.log(proxy1.secret);
// Expected output: "easi ... shhhh!"
new Proxy(target, {
get(target, property, receiver) {},
});
get() . this .
get() .
handler.get() .
.
proxy[foo]
proxy.barObject.create(proxy)[foo]Reflect.get()[[Get]] undefined , ..
const p = new Proxy(
{},
{
get(target, property, receiver) {
console.log(`called: ${property}`);
return 10;
},
},
);
console.log(p.a); // "called: a"
// 10
.
const obj = {};
Object.defineProperty(obj, "a", {
configurable: false,
enumerable: false,
value: 10,
writable: false,
});
const p = new Proxy(obj, {
get(target, property) {
return 20;
},
});
p.a; // TypeError is thrown
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver |
This page was last modified on 2025 2 11 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 |