Here you can find the source of difference(t)
Array.prototype.difference = function(t) { // s.difference(t) --> // new array with elements in s but not in t var t = t.toHash(); var r = [];/*from w w w. j av a 2 s .c om*/ this.forEach(function (item) { if (!t.containsKey(item)) r.push(item); }); return r; }
Array.prototype.diff1 = function(compare) { return this.filter(function(elem) {return elem!=compare;})
function getJSON(yourUrl) { var Httpreq = new XMLHttpRequest(); Httpreq.open("GET", yourUrl, false); Httpreq.send(null); return Httpreq.responseText; Array.prototype.diffArrays = function(a) { return this.filter(function(i) { return a.indexOf(i) < 0; ...
function diffArray(arr1, arr2) { var newArr = arr1.concat(arr2); function checkItems(item) { if (arr1.indexOf(item) === -1 || arr2.indexOf(item) === -1) { return item; return newArr.filter(checkItems); diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
function diffArray(arr1, arr2) { var diff1 = []; var diff2 = []; diff1 = arr1.filter(function(value) { return arr2.indexOf(value) < 0;}); diff2 = arr2.filter(function(value) { return arr1.indexOf(value) < 0;}); return diff1.concat(diff2); diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
function diffArray(arr1, arr2) { let newArr1 = []; let newArr2 = []; let sliced = []; for (let y = 0; y < arr1.length; y++) { if (arr2.includes(arr1[y]) === false) { newArr1.push(y); for (let i = 0; i < newArr1.length; i++) { sliced.push(arr1.splice(newArr1[0], 1)); for (let x = 0; x < arr2.length; x++) { if (arr1.includes(arr2[x]) === false) { newArr2.push(x); for (let j = 0; j < newArr2.length; j++) { sliced.push(arr2.splice(newArr2[0], 1)); let finalArr = [].concat.apply([], sliced); return finalArr; diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);