利用 ES6 新增的数据结构 Set 实现

let arr = [20, 28, 28, 30, 28, 50, 40];
let res = [...new Set(arr)];

console.log(res); // [20, 28, 30, 50, 40]

文章的内容/灵感都从下方内容中借鉴


Noxus丶SJ
7 声望0 粉丝

快乐的前端小菜鸟 [链接]