获取2个数组中不同的元素
程序员文章站
2024-01-06 14:55:40
...
方法一
function (oldVal,newVal){
var removeItemFieldName = '';
for(let i in oldVal){
var stra = oldVal[i];
var count = 0;
for(let j in newVal){
var strb = newVal[j];
if(stra == strb){
count ++;
}
}
if(count=== 0){
removeItemFieldName=stra;
}
}
reture removeItemFieldName
}
方法二:
getDiff(arr1, arr2) {
return arr1.filter(key => !arr2.includes(key))
},
转载于:https://www.jianshu.com/p/13fb87e65b57