ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## differenceBy + [link](./differenceBy "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L5621 "View in source.") + [npm](https://www.npmjs.com/package/lodash.differenceby "See the npm package.") ``` _.differenceBy(array, [values], [iteratee=_.identity]) ``` 这个方法类似 `_.difference`,除了它接受一个 iteratee 调用每一个数组和值。iteratee 会传入一个参数:(value)。 ### 参数 1. array (Array) 需要处理的数组 2. [values] (...Array) 用于对比差异的数组 3. [iteratee=_.identity] (Function|Object|string) 这个函数会处理每一个元素 ### 返回值 (Array) 返回一个差异化后的新数组 ### 示例 ``` _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor); // => [3.1, 1.3] // 使用了 `_.property` 的回调结果 _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); // => [{ 'x': 2 }] ```