ES6数组去重

let arr1 = [1, 2, 3, 2, 5, 6, 3]
let arr2 = [5, 2, 3, 4, 6, 7]

// 合并数组
let arr3 = [...arr1, ...arr2]
console.log(arr3) // [1, 2, 3, 2, 5, 6, 3, 5, 2, 3, 4, 6, 7]

// 数组去重
let arr4 = new Set(arr3)
arr4 = [...arr4]
console.log(arr4) // [1, 2, 3, 5, 6, 4, 7]

posted @ 2021-06-02 15:30  wfc139  阅读(20)  评论(0编辑  收藏  举报