intersectionBy source npm

_.intersectionBy([arrays], [iteratee=_.identity])

这个方法类似 _.intersection,除了它接受一个 iteratee 调用每一个数组和值。iteratee 会传入一个参数:(value)

参数

  1. [arrays] (...Array)

    需要检索的数组

  2. [iteratee=_.identity] (Function|Object|string)

    这个函数会处理每一个元素

返回值 (Array)

返回数组中共享元素的新数组

示例

_.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
// => [2.1]

// 使用了 `_.property` 的回调结果
_.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }]