Skip to content

difference

js
_.difference(array, [values])

创建一个 array 值数组,这些值不包含在其他给定数组中,使用 SameValueZero 进行相等性比较。结果值的顺序和引用由第一个数组决定。

¥Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.

注意:与 _.pullAll 不同,此方法返回一个新数组。

¥Note: Unlike _.pullAll, this method returns a new array.

新增于

¥Since

0.1.0

参数

¥Arguments

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

    ¥array (Array): The array to inspect.

  2. [values] (...数组):要排除的值。

    ¥[values] (...Array): The values to exclude.

返回

¥Returns

(数组):返回新的过滤值数组。

¥(Array): Returns the new array of filtered values.

示例

¥Example

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

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