// 数组去重 ES6
// 1.使用filter去重
let arr=[2,3,4,3,4,3,4,6];
let arr1=arr.filter(function(item,index){
return arr.indexOf(item)===index;
});
console.log(arr1);//[ 2, 3, 4, 6 ]
//2.Set 数组去重
let item = [1,2,3,3,5,6,6,4];
let items = new Set([1,2,3,4,6,3,4]);
let arr = Array.from(items);
//还可以用于字符串去重
[...new Set('ababbc')].join('')// "abc"
//3.使用set add方法去重
const s = new Set();
[2, 3, 5, 4, 5, 2, 2].forEach(x => s.add(x));
let arr3 = Array.from(s);
console.log(arr3);
// 4.rest Set 剩余参数去重
let arr2 = [1,2,3,3,5,6,6,4];
let arr1=[...new Set(arr)];
console.log(arr1);//[ 1, 2, 3, 5, 6, 4 ]