var a = [1, 2, 3, 4, 5],
b = [1, 2, 3, 4, 5, 6];
function diff (a, b) {
if (a.length > b.length) {
return _.difference(a, b);
} else {
return _.difference(b, a);
}
}
console.log(_.difference(b, a)); // [6]
function diff(a1, a2) {
return a1.filter(i=>a2.indexOf(i)<0)
.concat(a2.filter(i=>a1.indexOf(i)<0))
}
function compare(a1, a2) {
return a1.length == a2.length && a1.every((v,i)=>v === a2[i])
}
const diff = function(a1, a2) {
return a1.filter(i=>!a2.includes(i))
.concat(a2.filter(i=>!a1.includes(i)))
}
https://jsfiddle.net/Stalk/7h5ahq5k/9/