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)
Array.prototype._map = function(fn,cbThis){
let This = cbThis || null
let newArr = []
this.reduce(function(total,item,index,arr){
newArr.push(fn.call(This,item,index,arr))
},null)
return newArr
}
console.log([1,2,3]._map(function(item,index){
return item+1+index;
},1))