作用:为了改变函数体内部 this 的指向

obj.call(thisObj, arg1, arg2, ...); obj.apply(thisObj, [arg1, arg2, ...]);

两者作用一致,都是把obj(即this)绑定到thisObj,这时候thisObj具备了obj的属性和方法。或者说thisObj『继承』了obj的属性和方法。

唯一区别是apply接受的是数组参数,call接受的是连续参数。

 

相关文章:

  • 2021-11-06
  • 2022-02-25
  • 2021-10-13
  • 2021-07-30
  • 2022-01-24
  • 2021-09-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-30
  • 2021-08-11
  • 2021-06-24
相关资源
相似解决方案