Array.prototype.myMap = function (fn) { return this.reduce((pre, cur, i, arr) => { pre.push(fn.call(this, cur, i, arr)) return pre; }, []) } const arr =[1,2,3]; const arr2 = arr.myMap(function(item,i,arr){ return item*2 }); console.log(arr2); //输出[2,4,6]