在zepto.js中看到这样的代码:
if (Array.prototype.reduce === undefined)
Array.prototype.reduce = function(fun){
//...省略好多代码
accumulator = fun.call(undefined, accumulator, t[k], k, t);
//...省略好多代码
}
这里的参数'fun'调用使用了call的形式,有必要吗?有什么意义?
functionA.call(undefined) 和 functionA() 在我看来是没有什么区别的,他们内部的this都是指向windows对象.
补充测试:
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
为了传参数为了传参数
给你传入的fun函数传递参数。
函数的几种调用方法