differenceBy
Returns the difference between two arrays, after applying the provided function to each array element of both.
- Create a
Set
by applyingfn
to each element inb
. - Use
Array.prototype.map()
to applyfn
to each element ina
. - Use
Array.prototype.filter()
in combination withfn
ona
to only keep values not contained inb
, usingSet.prototype.has()
.