Appearance
uniqBy
Create an array by removing duplicate elements from the result of the given function.
Example
uniqBy(
[
{ id: 1, name: 'user1' },
{ id: 1, name: 'user2' },
{ id: 2, name: 'user3' },
],
(user) => user.id
)
// => [{ id: 1, name: 'user1' }, { id: 2, name: 'user3' }]
Link
Playground
const { uniqBy } = require('rhodash') uniqBy([ { id: 1, name: 'user1' }, { id: 1, name: 'user2' }, { id: 2, name: 'user3' }, ], user => user.id)