ES6数组去重
来源:互联网 发布:免费hifi播放软件 编辑:程序博客网 时间:2024/06/07 10:51
使用ES6的新语法对数组去重,相比ES5省去了排序再做双重For循环
(function() { 'use strict'; let arr = [1, '1', 2, '2', 3, '3', 3, '3', 2, '2', 1, '1']; let new_set = new Set(arr); let new_arr = Array.from(new_set); console.log(new_arr);})();
阅读全文