difference-with

v4.17.15arrow_drop_down
v4.17.15
v4.17.11
STATUS
Passing
DOWNLOADS
151
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
4 years ago
SIZE
N/A
This method is like `_.difference` except that it accepts `comparator` which is invoked to compare elements of `array` to `values`.
2 contributors
Install difference-with as a package?
Copied
npm i @bit/lodash.lodash.difference-with
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
differenceWith (
array:Array,
values:...Array?,
comparator:Function?
) : Array

This method is like difference except that it accepts comparator which is invoked to compare elements of array to values. The order and references of result values are determined by the first array. The comparator is invoked with two arguments: (arrVal, othVal).

Note: Unlike pullAllWith, this method returns a new array.

Example
const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]

differenceWith(objects, [{ 'x': 1, 'y': 2 }], isEqual)
// => [{ 'x': 2, 'y': 1 }]
Arguments
array: Array

The array to inspect.

values: ...Array?

The values to exclude.

comparator: Function?

The comparator invoked per element.

Returns
Array

Returns the new array of filtered values.

Help and resources