//程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。 const arr = [1, 2, 3, 4]; Array.prototype.myMap = function(func) { const arr = []; for (let i = 0; i < this.length; i++) { arr.push(func(this[i], i, this)); } return arr; } console.log(arr.myMap((i) => 2 * i));