ES6数组去重及ES5数组去重方法

参考地址:http://www.cnblogs.com/thinkingthigh/p/9711736.html

去重

// ES6:使用Set 对象

 let array = [1, 1, 1, 1, 2, 3, 4, 4, 5, 3];
 let set = new Set(array);
 console.log(set);


// ES5: 使用forEach 遍历, indexOf 判断是否存在,push将不存在的添加到数组。

posted @ 2022-12-06 22:20  轻风细雨_林木木  阅读(2)  评论(0编辑  收藏  举报