经典面试题(使用reduce实现map)

// 使用reduce实现map Array.prototype.myMap = function (fn, callbackThis) { var _callbackThis = callbackThis || null; return this.reduce((prev, cur, index, array) => { prev[index] = fn.call(_callbackThis, cur, index, array); return prev; }, []) }

    推荐阅读