function arrComparison(oldArr, newArr) {
var oldArr = oldArr;
var newArr = newArr;
var distinct = [];
var tmp = oldArr.concat(newArr);
var o = {};
for (var i = 0; i < tmp.length; i++)(tmp[i] in o) ? o[tmp[i]]++ : o[tmp[i]] = 1;
for (x in o)
if (o[x] == 1) distinct.push(x);
return distinct;
}
取出两个数组不相同的元素并返回到新的数组里面
最新推荐文章于 2024-07-01 11:06:28 发布