uniq

array

Creates a duplicate-free version of an array, using SameValueZero for equality comparisons.

Signature

uniq<T>(array: T[]): T[]

Parameters

NameTypeDescription
arrayT[]The array to inspect

Returns

T[] - Returns the new duplicate free array

Examples

Basic Usage

import { uniq } from 'dashlite'

const result = uniq([2, 1, 2])
console.log(result)

Output:

[2, 1]

With Strings

import { uniq } from 'dashlite'

const result = uniq(['a', 'b', 'a', 'c', 'b'])
console.log(result)

Output:

["a", "b", "c"]

Available since version 1.0.0