关于返回数组元素平方的一道面试题
Posted at 2019-12-31 JavaScript 面试题 Array
12
let arr = [1, 2, 3];console.log(arr.square()); // [1, 4, 9]
12345
Array.prototype.square = function () { return this.map(function (item) { return item * item; });};
peace✌️
Previous post: 2019:我这一年 Next post: 面向百度(代指搜索引擎)编程的朋友