unique
Remove duplicate values from an array and return a new array of unique items, preserving the order of first appearance.
Usage
unique removes duplicate elements from an array.
import { unique } from '@movk/core'
const numbers = [1, 2, 2, 3, 3, 4]
const uniqueNumbers = unique(numbers)
console.log(uniqueNumbers) // [1, 2, 3, 4]
const strings = ['a', 'b', 'a', 'c']
const uniqueStrings = unique(strings)
console.log(uniqueStrings) // ['a', 'b', 'c']
API
unique<T>(arr)
Remove duplicate values from an array and return a new array of unique items.
Parameters
arr
T[] required
The array to deduplicate.
Returns
returns
T[]
A new array with duplicates removed.
Changelog
No recent changes