1. Array.prototype.myReduce = function (cb, initialValue) { let pre = initialValue ? initialValue : 0; const _reduce = () => { for (let i = 0; i < this.length; i++) { pre = cb(pre, this[i]); } }; _reduce(); return pre; };

相关推荐

牛客网
牛客企业服务