Answers for "compare two arrays js"

2

es6 compare two arrays

let difference = arrA.filter(x => !arrB.includes(x));
Posted by: Guest on September-24-2020
6

javascript compare arrays

Array.prototype.equals = function(arr2) {
  return (
    this.length === arr2.length &&
    this.every((value, index) => value === arr2[index])
  );
};

[1, 2, 3].equals([1, 2, 3]);	// true
[1, 2, 3].equals([3, 6, 4, 2]);	// false
Posted by: Guest on October-07-2020
2

javascript Compare two arrays regardless of order

const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);

// Examples
isEqual([1, 2, 3], [1, 2, 3]);      // true
isEqual([1, 2, 3], [1, '2', 3]);    // false
Posted by: Guest on July-02-2020

Code answers related to "compare two arrays js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language