小谢第6问:js中,filter函数是怎么使用的

数组的常用方法filter,今天在做数组筛选的时候用到需要将有重复的数组去除,因此用到这个函数,主要用到--

择需要的属性,最终留下想要的数组,如果刚开始的话可以看下下面代码

1 let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
2 
3 let res = nums.filter((num) => {
4   return num > 5;
5 });
6 
7 console.log(res);  // [6, 7, 8, 9, 10]
原文地址:https://www.cnblogs.com/xieoxie3000question/p/12988205.html