Skip to content

uniq

js
_.uniq(array)

创建一个数组的无重复版本,使用 SameValueZero 进行相等性比较,其中仅保留每个元素的第一次出现。结果值的顺序由它们在数组中出现的顺序决定。

¥Creates a duplicate-free version of an array, using SameValueZero for equality comparisons, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array.

新增于

¥Since

0.1.0

参数

¥Arguments

  1. array (数组):要检查的数组。

    ¥array (Array): The array to inspect.

返回

¥Returns

(数组):返回新的重复释放数组。

¥(Array): Returns the new duplicate free array.

示例

¥Example

js
_.uniq([2, 1, 2]);
// => [2, 1]

Lodash v4.17 中文网 - 粤ICP备13048890号