javascript two arrays difference code example
Example 1: javascript difference between two arrays
let difference = arr1.filter(x => !arr2.includes(x));
Example 2: array differenc javascript
let difference = arr1.filter(x => !arr2.includes(x));
Example 3: diff two arrays javascript
function diffArray(arr1, arr2) {
return arr1
.concat(arr2)
.filter(item => !arr1.includes(item) || !arr2.includes(item));
}
Example 4: compare two arrays and return the difference javascript
let difference = arr1
.filter(x => !arr2.includes(x))
.concat(arr2.filter(x => !arr1.includes(x)));