Returns a new array that removes elements for which uniqFn returned duplicate elements.
uniqFn
The first occurrence of each element is kept.
Optimized implementation using for...of loop instead of forEach for better performance.
the input array
a function that returns the value to check for duplicates
a new array with unique elements
Unique elements by length.
import { uniqBy } from "@trashpanda001/helpers/array"uniqBy(["cat", "dog", "raccoon", "meow", "woof"], (x) => x.length)// ["cat", "raccoon", "meow"] Copy
import { uniqBy } from "@trashpanda001/helpers/array"uniqBy(["cat", "dog", "raccoon", "meow", "woof"], (x) => x.length)// ["cat", "raccoon", "meow"]
Returns a new array that removes elements for which
uniqFn
returned duplicate elements.The first occurrence of each element is kept.
Optimized implementation using for...of loop instead of forEach for better performance.