function diff(arr1, arr2) { var newArr = []; // Same, same; but different. var a = arr1.filter(function(e){ return arr2.indexOf(e) < 0; }); var b = arr2.filter(function(e){ return arr1.indexOf(e) < 0; }); newArr = a.concat(b); return newArr; } diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);