获取2个数组中不同的元素
2019-03-14 本文已影响0人
Amy_yqh
方法一
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))
},