Skip to content

xorBy

js
_.xorBy([arrays], [iteratee=_.identity])

此方法与 _.xor 类似,不同之处在于它接受 iteratee,调用该方法可生成比较 arrays 的每个元素的标准。结果值的顺序由它们在数组中出现的顺序决定。迭代器使用一个参数调用:(value)。

¥This method is like _.xor except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which by which they're compared. The order of result values is determined by the order they occur in the arrays. The iteratee is invoked with one argument: (value).

新增于

¥Since

4.0.0

参数

¥Arguments

  1. [arrays] (...数组):要检查的数组。

    ¥[arrays] (...Array): The arrays to inspect.

  2. [iteratee=_.identity] (函数):每个元素调用迭代器。

    ¥[iteratee=_.identity] (Function): The iteratee invoked per element.

返回

¥Returns

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

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

示例

¥Example

js
_.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
// => [1.2, 3.4]

// The `_.property` iteratee shorthand.
_.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 2 }]

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