allUniqueBy
Checks if all elements in an array are unique, based on the provided mapping function.
- Use
Array.prototype.map()
to applyfn
to all elements inarr
. - Create a new
Set
from the mapped values to keep only unique occurrences. - Use
Array.prototype.length
andSet.prototype.size
to compare the length of the unique mapped values to the original array.