how can i compare two arrays javascript code example
Example 1: es6 compare two arrays
let difference = arrA.filter(x => !arrB.includes(x));
Example 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