compare two arrays and return the difference javascript

Solutions on MaxInterview for compare two arrays and return the difference javascript by the best coders in the world

showing results for - "compare two arrays and return the difference javascript"
Amelie
21 Feb 2020
1let difference = arr1.filter(x => !arr2.includes(x));
Brady
20 May 2018
1function diffArray(arr1, arr2) {
2  return arr1
3    .concat(arr2)
4    .filter(item => !arr1.includes(item) || !arr2.includes(item));
5}
Mahamadou
13 Oct 2019
1const equals = (a, b) => JSON.stringify(a) === JSON.stringify(b);
2let arr1 = ['1','2'];
3let arr2 = ['1','2'];
4equals(arr1,arr2)//this return false , if not equal then its return false
Tristen
30 Oct 2019
1let difference = arr1
2                 .filter(x => !arr2.includes(x))
3                 .concat(arr2.filter(x => !arr1.includes(x)));
4
Manuel
09 Aug 2020
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"]
queries leading to this page
javascript compare two multidimensional arrayshow to compare two same array in javascriptget diff between two arrays javascriptjavascript compare two arrayshow to filter difference between two arrays in javascripthow to get the difference between two arrays in javascriptcheck difference between two arrays javascriptangular check diffeence inside items of arrayfind the difference between two arrays javascriptcheck differnts between 2 arraysjavascript diff indexjs get difference of two arraysnode js get difference between arrayscompare two array elements in jsdifference between two arrayjs difference of two arrays of objectarray get diffhow to find difference in javascript array 3fcompare two arrays javascript by valuesjavascript compare two arrahow find the difference between two arrays jsdifference between two arraysfind difference in elements between 2 arrayscompare two arrays jshow to compare the contents of two arrays jsjavascript compare field in two arraysis node js array differencejavascript compare 2 arraysloop finding differences in values of array javascripthow to compare arrays javascriptdifference of 2 arrays in javascripthow to check for the difference of two items in an arry in javscriptjs array diffhow to know what is different in two arrays in jscalculate the difference between list within list jsjavascript differemce between two arraysjavascript difference between 2 arraysjs look for difference in two arraysdifference two arrays arrayfind different values from 2 lists jshow to compare the values of two arrays in javascripthow to calculate array difference in javascriptreturn difference between 2 arrays in nodejsdifference in array javascriptjavascript array minus arraycompare size of 2 arrays javascriptcomparing the values of 2 arrays in javascriptdisplay the changes between two arrayjavascript combine 2 arrays difference betweencompare elements of 2 arrays javascripthow to compare two arrays in javascriptarray differenc javascriptdifference javascript arrayscompare between 2 array jsdifference between two string arrays jsjavascript compare arrays for equalityhow to take diff of array javscriptjavascript array disjunctionhow minus something from array javascripthow to find difference of two arrays in javascriptnodejs similarity in 2 arraysfind intesect of two arrays jsjavascript calculate array difference from two arraysbetwen 2 array diffrencehow to have between list in javascriptchecking the difference between two arrays javascriptjavasctipt find array differencehow to compare 2 different arrays in javascriptcompare values of two arrays javascriptreturn all difference between two arrays jscompare lenght two arrays javascriptjs get difference between two arrayshow to compare elements in two different arrays javascriptjavascript get left elements two arraysreturning unique differences between two arraysdifference array in javascriptget difference of arrayshow to compare two values of an array jsjs array minus valuejavascript get difference of two arraysjavascript check difference between two arrayshow to compare two arrays and output the different element javascriptcomparing two arrays javascript and substract the differencecompare two arrays in javascript mdncompare values from two arrays javascriptfind the difference between two arrays quicklynodejs find difference in 2 arrayscompare two arrays javascript to find differencesjs find the difference between2 arraysget differences between two primitive arrays javascriptnode js two array differencecalculate difference between array and a number javascriptjavascript compare 2 arrays for differenceshow to get the difference extra item of array in javascriptjavascript check array differencejavascript except two arraysreturn diference between two arraysreturn new data array from two arrays javascripthow to get difference of two arrays of objects javascriptjavascript diff in arraydiff in array in jsjavascript find all difference between two arrayswrite a function to return difference between two arrays in javascriptget difference between arrays jsget right rest items compare two arrays javascripthow to find the difference between two arrays in javascriptjavascript array compare elementsjavascript difference of 2 arraysjs get after two values arraycompare two arrays in javascriptcombines two array a b c d e array in javascriptjavascript find array diffget difference of two arrays javascriptget differences between two arrays by keycompare two array elements javascriptjs number difference in arrayjs get diff between elelments in arrget two values from an array javascriptarray 1 minus array 2 javascriptfind difference between two javascript codescompare two array values in javascriptdiff two arrays javascriptjavascript compare two arrays for equalitydifference between list jsdifference array tefind difference between two array javascripthow to find the difference of element array in javascriptdifference between two arrays javascripthow to compare two arrays javascriptdifference of two arrays jsarray minus array javascripta method to find the differfence in an two arraycompare 2 arrays in javascriptthe difference between two arraycomparing two arrays in javascriptdiff two array javascriptjavascript compare arrays obtain differentsget difference between 2 arrays javascriptjavascript difference in arrayjs check difference between two arraysdifference between two array in javascripthow to compare two values of different arrays using javascriptnodejs difference between two arraysfilter two array find the differentdifferent between arraysor two arrays js on arrayjs array diff between 2 arraysdifference of two arrays javascriptget the difference of 2 array javascriptjavascript how to compare two arraysfind 2 array value in javascriptjavascript diff two arraydifference between array or new array in jshow to find array difference in javascript and make arraymerge with differene between 2 arrays javascripthow to compare two arrays in javascript if conditiona method to find the differfence in an arrayhow to find the difference between 2 lists in jshow to return values inside two array in javasceriptarray dif jsjavascript symmetric difference between arraysget difference between two arrays jsjavascript make multiple arrays onejs compare 2 arraysjs comparing two arraysjavascript diff between two arraysdiff of 2 arrays in jsarray diff javascriptdifference in array jsjavascript return difference between two arraysjavascript how to find the symmetric difference of two arrayscompare two arrays of string and remove the differencesjavascript es6js difference between two arrays of objectsjavascript to compare two arrays for additions or sucompare the difference between two arrays jshow to compare two array javascriptreturn new data from two arrays javascriptdifference between arrays javascriptjs difference of arraydifference function in array javascriptjavascript two arrays differencejs compare 2 arrays valuesjavascript difference between 2 arraydifference between arraysjavascript two arrays comparejs difference between arrayarray between two numbers javascriptcompare 2 arrays and get the difference javascriptjavascript get difference between two primitive arraysjs two array differencehow to compare two arrays in javascript demohow to find different in one array jscompare 2 array javascriptjs check difference between arraydifference between arrayhow to make difference set from two arrays in javascriptloop finding differences in array javascriptjs diff arraysjs 2 arrays find differencesjavascript in two or more array compare element and get only elements present in all arrayjavascript compare two arrays have same elementscompare two arrays and find differencechange javascript array according to diffget the difference between 2 array jscompare two array in javascriptget the similarities between to arrays javascriptdifference between array is foundjavascript array differencesget elements diff in arrays javascriptcompare two arrays in javascript and return their symmetric arrays in any ordercalculate the difference of two array in javascriptjavascript diference two arrayshow to compare elements of two array in javascriptfind the diffrence between 2 arrayjs array difference only one valuejavascript differences length between two arrays compare array of numbers javascriptdifference bewteen two array javascriptarray diff in jsfind difference between two array using filterfind the differnece between two string arrays jsjs return difference between two arraysjavascript compare two array elementfind any value between two arrays javascript someget diff of arrays and keep common values javascripthow to use lodash to get difference of 2 arrays for only one arraysymmetric difference of two arrays javascriptarray difference in node jsjs get diff between tow arraysjavascript subtract two arraysjavascript how to compare differences of two arraysjavascript check array all differencejavascript difference arrayjavascript difference between two arraysarray diff in javascriptarray difference jshow to compare two arrays and return the difference javascriptsub 2 array jscompare two arrays equal javascripthow to get the difference between items in an array in javascriptcompare two arrays and return the difference in an array javascriptcompare items of two arrays javascriptarray get diff jsjs diff c3 a9rence entre array 3c 3e et 5b 5ddifference between 2 arrayarray difffernce jsget difference between two large arrays javascriptcompare two element of same array javascriptfilter diff in array jsjavascript 2b compare array of objects and get differencereturn an array with difference between arrays in nodejscheck 2 arrays for difference 2b javascriptjavscript array difffilter out differences of two arraysdifference between array and new array javascriptcan you use 3d 3d to compare two arrays in javascripthow to find difference types of arrays in javascriptjs compare equality of arraysconcat 2 arrays jshow to compare elements of two arrays in javascript and return different valuejavascript to compare two arrays for additions or subtractions of elementsjs array difference multiple valuesget the difference between two arraysjavascript differences between two arrays lengthhow to make arrays of arryas with diff arrays in jsarray diff function in nodecomparing two array values in javascriptarray differencereturn difference of two arraysdifference two array javascriptdifference between 2 arrays jssubtract list to another javascriptfunction to find the differice in arraysjavascript difference of two arraysjs return the difference between two arraysjs diff listsfind difference in two string arrays javascriptcompare 2 arraysa in jshow can i compare 2 arrays and see if they are the same 3f jsget different elements from two arrays jsset difference javascript arrayhow to compare all elements of two arrays in javascriptarray diff javascriptdifference in number between two arrays javscriptjs difference of two arraysdifference between 2 string arrayfind difference in array javascript javascript array differencediff between two array in jscomparison of two arrays in javascripthow to comapre two array and get differenceget property difference from2 arraydiff two arrays in jshow to compare 2 elements in different arrays in javascriptjs diff two arrayshow to find difference between two arrays in javascripthow to find difference between two array of objects javascriptget the difference between two arrays javascriptjs two arrays diffcompare differences between arrays jshow javascript arrays differcompare two arrays of string and remove the differences javascript es6javascript array compare differencedifference in two arrays javascriptarray diff jshow to see detect changes between two arrays javascriptdiff between two arraysdifference of two arrays in javascriptcompare 2 arrays and and add remaingreturn matched values between two arrays javascritcompare 2 arrays and return the difference javascriptcreate objects from two arrays javascriptfind difference in array element javascriptget diff of arrays javascriptjs find difference between two arrayscompare two array in jsjs efficient diff arrayscollect matching data from two arrays in js compare elements of multiple array javascripthow to find the difference between two array item indexjs return diff or arrayjavascript get array differencedifferences in two arrays javascriptjavascript log differences between two arraysjs different part of two listcheck difference between two arraysjavascript compare two arrays find differences onlinefunction arraydiff 28a 2c b 29 7b 7ddiffence between two arrays javascripthow to compare contents of two arrays in javascripthow to find array difference in javascripttwo array compare and matching value return in javascriptcompare equal of two arrays javascriptjs compare arrays with different orderjs easiest way to expose differense in listsarray of difference between to arrrays javascriptcompare between 2 arrays are equal javascriptjavascript compare arrays for differencesjs get 2 array differencejavscript comparing two arrays to see what they both havefind difference between two elements in an array jscompare arrays javascript 2b1javascript compare two arrays for differencesarray difference in javascriptarray new array javascript differencecompare arrays javascriptjavascript es5 compare arrays return differencejavascript compare two arrays equaljavascript compare items in two arraysarray minus valuedifference between to arraydiff arrays in jsfind different between two arrays with keysjavascript comparing arrays and finding diffreceshow to get the difference of two arrays in javascrptjs array compare 2 elements valuehow to compare to arrays in javascriptcompare 2 arrays values and return the difference javascripthow to compare 2 elements in arrays in javascriptcompare elements two arrays javascriptcheck the data difference in the array javascriptjs difference between two arrayscompare two array of numbers jsfind differences between two arrays javascriptjavascript show difference between arraysget array difference javascriptcompare two arrays and find difference jsjavascript difference between two arrays of stringshow to compare two arrays values in javascriptjavascript compare two arrays return differencejavascript compare arrays return differencehow to get multiple values in array javascriptdifference two arrays javascriptsubtract 2 arrays javascriptcompare two arrays to match their content javascriptget length of difference between two arrays javascriptjs es6 get difference between 2 arraysnode js array differencedifferent elements between two arrays javascriptcompare two array javascriptjavascript arrays differencehow to compare two array in javascript and return some elecmenjavascript differences between two arrayscompare two arrays of strings and return differencejavascript compare two elements in arraycompare two arrays javascript es6compare two array elements in javascriptarray1 3d array2 javascriptfind where an array is differentjavascript diff two arraysjs get diff array between elementsget difference betwwen arrays jsminus array from array javascriptreturn difference in two arraysjavascript array difference es6difference in two arrays in jsjavascript array diffdiff between 2 arrays javascriptreturn difrrent of two arrayshow to subtract numbers between two arrays in jsdifference between two array javascriptdifferen ce between array 5b2 5d and array 5b 5dcompare 2 array in javascriptfind the difference in number between two arrays javascriptcompare two array numbers javascriptcompare each element of two arrays jsjavascript compare arrays get return differencefind difference between two arrays javascriptjavascript difference arrayjavascript compare two arrays of objects return differencedifference in arrays jscompare values of two arrays javascript with different lengthfind the difference between two arrays in javascriptcompare two array data in javascriptcompare elements in one array javascriptjavascript check if two arrays have differencehow to find difference in arraydiffrence js divreference jsfind difference between two arraysget all the elements in array which differece is 2how to make compare between two arrays javascriptcompare two arrays and get the difference javascriptjs difference two arraysjavascript compare to arrays have different valuescompare two arrays diffall differences in 2 arrays javascripthow do you diff two arrays in javascriptdifference two arraysfunction compare arrays javascript get differencesarray a array b javascriptjavascript get difference between two arrayselement differente in array javascriptjs diff arrayarrays compare javascript return differencedifference between two array jshow to detect difference item of two arrays in javascripttwo array difference javascriptknow differnece between two arrays javascriptjavascript find list difference between two arrayshow to diff a values or array javascriptjavascript update array element difference onlyjs commun 2 array comparenode js to find array differencejavascript difference between arrays stringarray diffeence 2 jsarray is difference or not in javascriptcompare two arrays javascriptcompare the elements of two arrays javascriptjavascript difference 2 arraysfinding differences between arrays javascriptcompare 2 array values in javascriptreturn matching values from two arrays jsdifference between 2 arrays in javascriptjs find array difference between two arraysdiff of two arrays javascriptjavascript find array differencecompare two arrays find out differences javascriptarray difference methodnode js difference between two arraysget differences between two arrayscompare 2 array in jshow to get the difference of two arrays jsget difference between two lists javascripthow to diff 2 arraystwo int arrays compare in javascript how to compare to arrays and see which is difference javascriptreturn difference between two arrays jscheck similarity between two arrays javascriptget differences in object arraysdiff 2 arrays javascriptjavascript compare two arrays valuesdiference between two arrays jshow to get difference of array object in javascripthow to compare two different arrays in javascriptdiffence between two arrays es3 javascriptcompare two arrays based on one parameter and push into other arrayfind by comparision array javascriptobject array difference javascripthow to find differences in 2 arraysdifference between two arrays jsfind the difference between two points in arrayjs difference array get and findhow to compare two identical array in javascriptmost efficient way to compare two arrays javascriptcompare two lists and find differences javascriptarray find the different number javascriptcomparing two array in javascriptjavascript difference two arraysjavascript difference between two listsarray minus array jsjs get differences betweem array elementshow to extract different vbalues between two arrayshow to find diffference between onject and array in jsfind difference between two arrays in javascriptfind difference between two arrays objectarray disjunctionhow to compare two array in javascriptcompare two array and return same data javascriptget difference between arrays javascriptnodejs find difference between two arraysfunction arraydiff 28a 2c b 29 7b 7d javascriptcompare two arraycompare if two arrays are equal javascriptjavascript merge two associative arrayscompare values of 2 arrays in javascriptcompare two arrays which has more elements javascriptfind diffrence in two arrayjavascript subtract array from arrayarray diff javascriptcompare 2 arrays jsjavascript compute array diffshow to find the difference between two elements in array in javascripthow to compare the result of two arrays jsdiff two arrayscompare two arrays and find different items javascriptfind difference between two arrays javascript same lengthes6 two array compare and find differencearray diffirence javascriptjs get after two values at same arrayfind the difference between 2 arrays javascriptjs 2 array comparehow to array in difference array getjavascript array deltahow to compare two array in jsfind dffierence between 2 codes javascriptcompare 2 arrays and return new nodejsdiff array javascriptjavascript array compare 2 arrays and get the differencejavascript find diff between 2 arraysjavascript compare two listscomparing to two different arrays javascriptsubtract two arrays javascriptarray dfference in nodejsdifference between two arrays old javascriptjavascript compare multiple arraysfind difference between two elements in the same array jsfind difference of two arrays in jsdifference between two arrays in javascriptget property difference from 2 arraydifference of two arraysjavascript find difference between multiple arraysjavascript compare two arrays return differencejavascript compare arrays get differencejavascript get diffrence between arrayshow to compare two arrays and get the difference javascriptdifference from arrayall differents in 2 arrays javascriptlet difference 3d arr1 filter 28x 3d 3e 21arr2 includes 28x 29 29 3bin javahow to compare inside an arrayget difference between two arrays of objects es6simetric difference array javascripdifrence two arraysjavascript compare two arrays and return matchesget difference between two array javascriptreturn symmetric difference of the array javascriptjs diff between two arraysjavascript get the difference between two arrayshow to compare two array in javascirptfind difference of two elements in the array javascriptcompare two arrays in jsjavascript find difference between two arrayshow to make it diff from 2 arrays in jshow to find difference between two arrays jsjavascript remove diffrenece from arrayfunction arraydiff 28a 2c b 29 7bcalculate difference between two array elementjavascript compare two arrays per elementhow to compare two array elements in javascriptget the items that are difference in two arrays javascriptdifference 2 array javascriptjs get the difference between arrayjs get difference arrayscompare two arrays for same values jsjavascipt array difffind difference between 2 arrays javascriptfind the differnece between two arrays jstwo arrays need to compare javascriptdifference array methodjs compare two arraysjavascript return diff betwwen two arraysreturn difference of two lists javascriptcompare three arrays jsarray minues 2 arrays javascriptdiff arrays javascripta b in array jshow to get an array of differences from two arraysjs how to compare two arrayscomparing two arrays javascriptjavascript difference between arrays es5find difference between arrays javascriptjs get array differenceget different value from two array in javascriptjavascript show difference between two arraysjavascript compare two arrays and get the differencejs get diff between arraysnodejs find similarities in 2 arrayscompare two arrays and return the difference javascriptget diff value from array object javascriptjavascript find differences between two arraysjavascript find the difference between two arrayshow to compare elements of two arrays in javascript then make a new array with the differenceshow to compare elements in two arrays in javascriptcheck if there are differences between two arrays jslist get difference jsget diff number between array javascriptcompare two arrays diff javascriptfind similarities betweeen arrays jsjavascript array differencejavascript to array differnecesdifference between array javascriptfind array difference javascriptdifferents array emethods in jsget the object difference in two arrays javascriptes6 difference between two arraysmost efficient ways to compare two arrays jsjavascript array and java array differencedifference with arrayget diff element between two arrayscompare 2 arrays javascriptjavascript es6 compare two arrayscompare two arrays for equality javascriptcompare two number arrays javascriptcompare 2 array jsfind difference bt 2 arrayshow to 2 array compare jsjavascript find diffference between two arrayshow to take diff in same array javscript pramp diff between two stringsdiff arrays jshow to find difference between two arrays of objects in javascriptdiff between two arrays javascriptjs check differencehow to compare elements of two arrays in javascripttwo array compare in javascriptcompare two elements in array javascriptcompare 2 array values javascriptarray diff jsarraydiff 28 5b1 2c2 5d 2c 5b1 5d 29 3d 3d 5b2 5d in javascriptjavascript compare two array equaljavascript diff between arraycompare two arrays and return common values javascriptjavascript get differnce between two primitive arrayscompare two array elements in node jsjavascript keep similar data between two arrayshow to get difference of two arrays in javascriptcheck array difference jscompare elements of two arrays javascripttypescript compare two arrays find differencescomparing 2 arrays in javascriptjavascript compare 2 arrays get differencefind difference between 2 array jsdiff between array jsarray difference function javascriptreturn difference of two arrays javascriptcomparing two arrays in javascript returning differencesarray javascript array differencejs compare equality of two arrayshow to find different elements in two array in jshow to find the difference between two arrays of objects in javascriptcompare two arrays of different size jsjavascript 2b get differencec between original array and copied arrayjavascript difference between two arrays of objectscompare elements in two arrays javascripthow to compare two arrays elements in javascriptjavascript two array differencecompare value from two arrays javascriptdifference of arrays javascriptjs check differnce between 2 arrayjs array is diffrentcompare arrays and get the difference output javascripthow to get difference between two arrays in javascripthow to compare two different array in javascriptarray a 3darray b jsjavascript array list differencecompare two arrays values javascriptfind differences between two arrays js javascriptr programmatically get difference between two array elementsjavascript diff between two ararrayfind different elements in two arrays javascripthow to know what is change in two arrays in jsfind difference between two arrays jsarray methods to compare signature javascriptset difference of two arraysjs compare values in two arraysdifference array javascriptreturn data from from two array in javascriptes6 find difference between two arraysdifference in two arrays javascript es6compare two by two on array javascriptnodejs get difference between two arraysjavascript diff 2 arrayshow to find the difference between all elements in array in javascriptfind what is same between two arrays javascriptjs diff between arrayshow to find the difference between elements in array in javascriptfind the difference of 2 arrayjs difference arraysarrar difference jsjavascript difference between arraysjavascript print differences between two arraysdifference 28 29 of 2 arrays in jsdifference between and array in javascriptreturn matching element from two array javascriptcompare two array jsarray function diff of 2 arraysfunction array diff 28a 2c b 29 7b 7d javascriptfind differences between two lists nodejsfind difference between 2 colletions jshow to compare two values arrays in javascriptarray of arrays symmetric difference javascripthow to compare two arrays of index javascriptdiff array jscompare two and get the difference arrays typescriptjs array remove deltasfind the difference between array jsjavascript find difference between two arrays es6javascript array compare diferencesreturn difference between two arrays javascriptdifference array jsjavascript compare two arrays find differencesget difference of array javascriptjavascript get the difference number in arrayscompare the diff between two arrays and return the diffjavascript array diffjavascript array get differencejavascript 2 array diffcreate array between two values javascriptjs compare elements of 2 arrayshow to make it different from 2 arrays in jscompare indecies of two arrays javascripthow to compare two arrays in jscompare 2 array n javascriptjavascript difference arraysdifference of 2 arrays javascriptcalculate the delta between list within list jscompare two array and find arrays in javascriptarray difference in reactfind array diff 28 29 3bcelsiusvsfahrenheit comparing 2 lists javascriptjavascript comparing an 2 items in an arraycompare two arrays of different length javascriptget the difference between arraycompare between two arrays javascriptdifference arraydifference of two array in javascriptfastest way to get the difference two arrays javascriptjavascript how to compare diffenrces of two arraysjavascript array extract diferenthow to compare elements of two array in jscomapre two array java scriptget difference between two array jshow to find two array has difference in javascriptes6 array minus arraycompare two arrays and see which one is differentjavascript diff of arrayscompare two arrays using for loop and return the difference javascriptfind diff fbetween 2 collections jsdifference between 2 arrays javascriptjavascript difference between arrays not workingdiff between two array jscompare an array with another and return the difference javascriptjs find the difference between two arraysget the deffence between 2 arraycommon elements between multiple arrays jsdifference of array in javascriptarray difference javascriptget difference between two arrays javascriptjavascript compare values in two arrayscompare items in two arrays javascriptjavascript find out difference between two arrayscompare values in two arrays javascriptcompare arrays in javascriptarray diference in javascriptjavascript minus towo arrayget differenc between two array jsdifference b 2fw two arrayfind difference in two arrays javascriptwrite a function to return difference between two arrays js array differencejavascript arrays difference between concat and includeshow to compare between two arrays in javascriptjavascript difference items in 2 arraydifference in arraya in jacompare diff arrayjavascript compare two records from two arraysjavascript compare array diffjavascript xor two arrayscompare 2 arrays in jsjs array difference es6javascript diff arraysreturn diff between arrays jshow to find the object difference in an arraydifference two arrays jscompare two arrays and return the difference javascript