js两数组合并去重
2022-01-08 本文已影响0人
前端金城武
可以通过concat方法合并。但是concat并不能去重,需要使用new Set()方法去重
let a = ['1','2','4']
let b = ['1','3','5']
const x= [...new Set(a.concat(b))]
console.log(x)//['1','2','4','3','5']
可以通过concat方法合并。但是concat并不能去重,需要使用new Set()方法去重
let a = ['1','2','4']
let b = ['1','3','5']
const x= [...new Set(a.concat(b))]
console.log(x)//['1','2','4','3','5']