1、
const tempList = [1,2,3,4,5,6,7]
const arr = [1,2,3]
const obj = {}
(item => obj[`${item}`] = true) // 将需要对比的数组的值作为 obj的key
(item => if(!obj[item]) { (item) } ) // 这里是对比出来不同的元素
2、
const tempList = [1,2,3,4,5,6,7]
const arr = [1,2,3]
function compare ( num, list) {
for (var j = 0; j < ; j++) {
if (num === list[j]) {
return false; //如果传过来的元素在arr1中能找到相匹配的元素,返回fasle
}
}
return true;
}
for (let index = 0; index < ; index++) {
if(compare(tempList[index], arr )){ (tempList[index]);}
}