Function: uniq()
ts
function uniq<T>(array): T[];Removes duplicate values from an array while preserving order. 在保留顺序的前提下移除数组中的重复值。
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of array items / 数组元素类型 |
Parameters
| Parameter | Type | Description |
|---|---|---|
array | readonly T[] | The source array / 源数组 |
Returns
T[]
A new array with unique values / 去重后的新数组
Example
ts
uniq([1, 2, 2, 3, 3])
// => [1, 2, 3]Since
1.2.0