1. 使以下代码正常运行
const a = [1, 2, 3, 4, 5];
a.multiply();
console.log(a); // [1, 2, 3, 4, 5, 1, 4, 9, 16, 25]
***************************
var a = [1, 2, 3, 4, 5];
Array.prototype.multiply = function(arr) {
var temp = this.map(item => item * item);
return a.concat(temp);
}
网友评论