1function diffArray(arr1, arr2) {
2 return arr1
3 .concat(arr2)
4 .filter(item => !arr1.includes(item) || !arr2.includes(item));
5}
1function arrayDiff (a1, a2) {
2 var a = [], diff = [];
3 for (var i = 0; i < a1.length; i++) {
4 a[a1[i]] = true;
5 }
6 for (var i = 0; i < a2.length; i++) {
7 if (a[a2[i]]) {
8 delete a[a2[i]];
9 } else {
10 a[a2[i]] = true;
11 }
12 }
13 for (var k in a) {
14 diff.push(k);
15 }
16 return diff;
17}
18//usage:
19console.log(arrayDiff(['red', 'white','green'], [ 'red','white', 'blue']));//["green", "blue"]