Klay's Notebook

阿胡的的流水账


  • Home
  • Archive
  • Categories
  • Tags
  •   

© 2026 Klay-Clam

Theme Typography by Makito

Proudly published with Hexo

关于返回数组元素平方的一道面试题

Posted at 2019-12-31 JavaScript  面试题 Array 

题目

1
2
let arr = [1, 2, 3];
console.log(arr.square()); // [1, 4, 9]

实现

1
2
3
4
5
Array.prototype.square = function () {
return this.map(function (item) {
return item * item;
});
};

peace✌️

Share 

 Previous post: 2019:我这一年 Next post: 面向百度(代指搜索引擎)编程的朋友 

© 2026 Klay-Clam

Theme Typography by Makito

Proudly published with Hexo