5

第 33 题:如何去掉一组整型数组重复的值?

 2 years ago
source link: https://segmentfault.com/a/1190000040582129
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

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

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

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK