代码图示
var s = [23, 65, 98, 5]; Array.prototype.myMap = function (callback) { var newArray = []; this.forEach(value => newArray.push(callback(value))) return newArray; }; var new_s = s.myMap(function (item) { return item * 2; });
var s = [23, 65, 98, 5]; Array.prototype.myMap = function (callback) { var newArray = []; this.forEach(value => newArray.push(callback(value))) return newArray; }; var new_s = s.myMap(function (item) { return item * 2; });