es6 set

ES6 提供了新的数据结构 Set。它类似于数组,但是成员的值都是唯一的,没有重复的值。

let arr = [1,2,3,4,3,2,3,4,6,7,6];
let unique = (arr)=> [...new Set(arr)];
unique(arr);//[1, 2, 3, 4, 6, 7]

  

相关文章:

  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2018-06-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案