随笔分类 -  ECMAScript

摘要: 阅读全文
posted @ 2020-11-03 22:40 WP-WangPin 阅读(223) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-11-03 21:57 WP-WangPin 阅读(199) 评论(0) 推荐(0)
摘要:function square(arr) { //为数组 arr 中的每个元素求二次方。不要直接修改数组 arr,结果返回新的数组 return arr.map(x=>x*x); } 阅读全文
posted @ 2020-11-02 21:48 WP-WangPin 阅读(163) 评论(0) 推荐(0)
摘要:function remove(arr, item) { //返回arr中和item不相同的值 return arr.filter(x=>x!==item); } 阅读全文
posted @ 2020-11-02 21:01 WP-WangPin 阅读(2104) 评论(0) 推荐(0)
摘要:function sum(arr) { let count=0; arr.forEach(function(x){ count+=x; }) return count; } function sum(arr) { return arr.reduce((a,b)=>a+b,0); } 阅读全文
posted @ 2020-11-02 13:01 WP-WangPin 阅读(257) 评论(0) 推荐(0)