unionBy
Returns every element that exists in any of the two arrays at least once, after applying the provided function to each array element of both.
- Create a
new Set()
by applying allfn
to all values ofa
. - Create a
new Set()
froma
and all elements inb
whose value, after applyingfn
does not match a value in the previously created set. - Return the last set converted to an array.