Horje
comparing two arrays in javascript returning differences Code Example
javascript difference between two arrays
let difference = arr1.filter(x => !arr2.includes(x));
compare two arrays and return the difference javascript
let difference = arr1
                 .filter(x => !arr2.includes(x))
                 .concat(arr2.filter(x => !arr1.includes(x)));
comparing two arrays in javascript returning differences
function arrayDiff (a1, a2) {
    var a = [], diff = [];
    for (var i = 0; i < a1.length; i++) {
        a[a1[i]] = true;
    }
    for (var i = 0; i < a2.length; i++) {
        if (a[a2[i]]) {
            delete a[a2[i]];
        } else {
            a[a2[i]] = true;
        }
    }
    for (var k in a) {
        diff.push(k);
    }
    return diff;
}
//usage:
console.log(arrayDiff(['red', 'white','green'], [ 'red','white', 'blue']));//["green", "blue"]
compare two array in javascript
let arr1 = [1, 4, 7, 4, 2, 3];
let arr2 = [1, 2, 3, 4, 7, 18];

const is_same = arr1.length == arr2.length &&
  (arr1.every((currElem)=>{
    if(arr2.indexOf(currElem)> -1){
      return (currElem == arr2[arr2.indexOf(currElem)]);
    }return false
  })
)
console.log(is_same)




Javascript

Related
set in javascript Code Example set in javascript Code Example
open sans font Code Example open sans font Code Example
unwind check after null or undefined Code Example unwind check after null or undefined Code Example
node promisify without err Code Example node promisify without err Code Example
html button javascript void Code Example html button javascript void Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9