Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 529 Bytes

call.md

File metadata and controls

19 lines (14 loc) · 529 Bytes

实现 call

代码实现

提示:原生的 callapply 只有在参数处理方面有差异,因此这里直接调用了 apply 的实现

Function.prototype.call3 = Function.prototype.call || function (that) {
  const args = []
  for (let i = 0; i < arguments.length; i++) {
    args[i] = arguments[i]
  }
  return this.apply3(that, args)
}

参考: