Diff between two arrays
Mon Jan 31 2022 13:31:07 GMT+0000 (Coordinated Universal Time)
Saved by
@tcovington
// gives array of diff between the two
let difference = arr1
.filter(x => !arr2.includes(x))
.concat(arr2.filter(x => !arr1.includes(x)));
// separates the arrays so you know which array has which
let difference1 = arr1.filter(x => !arr2.includes(x));
let difference2 = arr2.filter(x => !arr1.includes(x));
content_copyCOPY
Comments