compare two arrays and find difference js code example
Example 1: javascript difference between two arrays
let difference = arr1.filter(x => !arr2.includes(x));
Example 2: compare two arrays and return the difference javascript
let difference = arr1
.filter(x => !arr2.includes(x))
.concat(arr2.filter(x => !arr1.includes(x)));