function foo (el) {
console.log(el, this.id);
}
var obj = {
id: 'aaa'
};
[2,6,3].forEach(foo, obj);

2aaa 6aaa 3aaa

通过call()、apply()进行绑定

相关文章:

  • 2022-12-23
  • 2021-07-02
  • 2021-07-18
  • 2021-07-21
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-26
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2022-01-31
相关资源
相似解决方案