let arr = [1,2,3] Array.prototype.myReduce = function(callback,initValue){ let arr = this for(let i=0;i<arr.length;i++){ initValue = callback(initValue,arr[i],i,arr) } return initValue } let sum1 = arr.myReduce((result,item,index)=>{ return result +=item },0) //sum1 -> 6