Returns a new array with duplicates removed based on the value of key. The first item for each key value is kept.
key
The source array.
The key to deduplicate by.
uniqueBy([{ id: 1, v: "a" }, { id: 1, v: "b" }, { id: 2, v: "c" }], "id")// => [{ id: 1, v: "a" }, { id: 2, v: "c" }] Copy
uniqueBy([{ id: 1, v: "a" }, { id: 1, v: "b" }, { id: 2, v: "c" }], "id")// => [{ id: 1, v: "a" }, { id: 2, v: "c" }]
Returns a new array with duplicates removed based on the value of
key. The first item for each key value is kept.