var arr = [123,123,143,434,5,365,546,1,2,3,4,5,6,75,43,3,2,2,21,1]
// 去重
var resarr = [...new Set(arr)]
console.log(resarr)
// 交集
var arr2 = [1,123,3,4342,554,36,7,676,5,587,321,4,324,3,345,2,365,546,1,2,3,4,5,6,]
var resarr2 = [...new Set(arr)].filter(item=>arr2.indexOf(item)>0)
console.log(resarr2)
// 并集
var union =[...new Set ([...arr,...arr2])]
console.log(union)
// 差集
var resarr4 = [...new Set(arr)].filter(item=> !(arr2.indexOf(item)>0))
console.log(resarr4)
// 集合的方法 使用
let s = new Set(['one','two','three'])
console.log(s)///Set(3) {"one", "two", "three"}
s.add('haha')
console.log(s)//Set(4) {"one", "two", "three", "haha"}
s.delete('one')
console.log(s)//{"two", "three", "haha"}
console.log(s.has('haha')) //true
s.clear()
console.log(s)///Set(0) {}
console