JavaScript中call方法详解

66 阅读1分钟

1:调用函数

fn.call() 

2:改变this指向

# 让fn中的this指向obj这个对象
fn.call(obj);
# 改变this指向,并传递参数
fn.call(obj,1,2);