Skip to content

Instantly share code, notes, and snippets.

@helabenkhalfallah
Created May 20, 2024 16:52
Show Gist options
  • Save helabenkhalfallah/b77267a473c45404684ef10bc85b2f0b to your computer and use it in GitHub Desktop.
Save helabenkhalfallah/b77267a473c45404684ef10bc85b2f0b to your computer and use it in GitHub Desktop.
Proxy Apply Example
const target = function(a, b) {
return a + b;
};
const handler = {
apply: function(target, thisArg, argumentsList) {
console.log(`Called with arguments: ${argumentsList}`);
return target.apply(thisArg, argumentsList);
}
};
const proxy = new Proxy(target, handler);
console.log(proxy(1, 2)); // Logs: Called with arguments: 1,2. Output: 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment