JavaScript handler.apply() 方法

2025 年 3 月 18 日 | 1 分钟阅读

handler.apply() 方法用于拦截函数调用。apply 陷阱返回值也将用作通过代理的函数调用的结果。

语法

参数

target: 目标对象。

thisArg: 用于调用的 thisArg。

argumentsList: 用于调用的参数列表。

返回值

此方法可以返回任何值。

浏览器支持

Chrome49
12
火狐18
Opera36

示例 1

输出

First exam.. 
proxy value(23, 54)

示例 2

输出

in apply 
in x(direct1, direct2) in apply 
in x(add, add) in apply 
in x(string, string)

示例 3

输出

56 
68
 
下一主题JavaScript handler