【问题标题】:What is the use of bind() over call()? What extra we can do with bind() which we cant with call()? [duplicate]bind() 比 call() 有什么用?我们可以用 bind() 做哪些我们不能用 call() 做的额外事情? [复制]
【发布时间】:2015-11-29 12:46:42
【问题描述】:

bind() 比 call() 有什么用? 什么额外的 bind() 可以做,而我们使用 call() 做不到?

【问题讨论】:

  • 谁能用例子解释一下 bind() 和 call() 的确切区别?

标签: javascript call bind apply


【解决方案1】:

call立即执行一个函数(使用重写的 this 值和一些参数)。

bind 创建一个调用旧函数的新函数(具有覆盖的this 值和一些默认 参数)。可以在未来的某个时间点调用该新函数(根据需要多次调用)。

【讨论】:

  • 你能举个例子吗?
猜你喜欢
  • 2023-03-13
  • 1970-01-01
  • 2016-02-09
  • 1970-01-01
  • 2017-08-11
  • 2021-03-24
  • 2014-06-30
  • 2019-09-08
相关资源
最近更新 更多