| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/apply | [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.apply() .
function sum(a, b) {
return a + b;
}
const handler = {
apply: function (target, thisArg, argumentsList) {
console.log(`Calculate sum: ${argumentsList}`);
// Expected output: "Calculate sum: 1,2"
return target(argumentsList[0], argumentsList[1]) * 10;
},
};
const proxy1 = new Proxy(sum, handler);
console.log(sum(1, 2));
// Expected output: 3
console.log(proxy1(1, 2));
// Expected output: 30
var p = new Proxy(target, {
apply: function (target, thisArg, argumentsList) {},
});
apply() .
this .
target
thisArg this
argumentsList
apply() .
handler.apply() .
.
proxy(...args)Function.prototype.apply() Function.prototype.call()Reflect.apply(). , .
.
const p = new Proxy(function () {}, {
apply(target, thisArg, argumentsList) {
console.log(`called: ${argumentsList}`);
return argumentsList[0] + argumentsList[1] + argumentsList[2];
},
});
console.log(p(1, 2, 3)); // ": 1,2,3"
// 6
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist |
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 |