JavaScript手写系列——手写reduce取代map
JavaScript手写系列-数组
1.使用reduce的方法实现map
完整代码
Array.prototype.map2 = function(callback,thisArg){
const _this = thisArg || null;
let res = this.reduce((total,currentValue,currentIndex,arr)=>{
total[currentIndex] = callback.call(_this,currentVal
原创
2021-04-23 12:52:11 ·
382 阅读 ·
0 评论