1 - lodash differenceThe lodash distance method can be used to find the difference between two arrays. Just give an array as the first argument, and another as the second, and what will be returned is a new array of values that are not in second array when comparing element by element.
Use _.differenceWith
, and pass a comparator which compares two arrays, as in:
_.differenceWith(a, b, _.isEqual);
As mentioned by @dsl101,
_.xor([1, 2, 3], [2, 3, 4]);
// [1, 4]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With