handler.apply()
The handler.apply() method is a trap for a function call.
Syntax
new Proxy(target, {
apply(target, thisArg, argumentsList) {
}
});
Parameters
The following parameters are passed to the apply() method. this is bound to the handler.
target- : The target callable object.
thisArg- : The
thisargument for the call.
- : The
argumentsList- : The list of arguments for the call.
Return value
The apply() method can return any value.
Description
The handler.apply() method is a trap for a function call.
Interceptions
This trap can intercept these operations:
- Function call:
proxy(...args) Function.prototype.apply()andFunction.prototype.call()Reflect.apply()
Or any other operation that invokes the [[Call]] internal method.
Invariants
If the following invariants are violated, the trap throws a TypeError when invoked.
- The
targetmust be a callable itself. That is, it must be a function object.