原文: https://www.yisu.com/zixun/730087.html
- js如何判断两个数组是否有重复的元素
let a=[1, 2, 3];
let b=[3, 5, 2];
newA = new Set(a);
newB = new Set(b);
let intersectionSet = new Set([...newA].filter(x => newB.has(x)));
console.log(intersectionSet);
let arr = Array.from(intersectionSet);
console.log(arr);
if(arr==[]){
console.log("两个数组没有重复元素");
}else{
console.log("两个数组有重复元素");
}
标签:arr,console,log,重复,js,let,数组,new
From: https://www.cnblogs.com/pine007/p/16938001.html