Array.prototype.mm= function (fn, int) {
let arr = Array.prototype.slice.call(this)
let res
let startIndex
if (int === undefined){
for (let i=0;i<arr;i++){
if (!arr.hasOwnProperty(i)) continue
startIndex = i;
res = arr[i]
break
}
} else{
res = int
}
for ( let i = int++ || 0; i<arr.length;i++){
if (!arr.hasOwnProperty(i)) continue
res = fn.call(null, res, arr[i], i, this)
}
return res
}
实现reduce
最新推荐文章于 2025-05-26 14:36:27 发布