mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, baseFlatten, isArguments, isArray, restParam) {
|
|
|
|
/**
|
|
* Creates an array excluding all values of the provided arrays using
|
|
* `SameValueZero` for equality comparisons.
|
|
*
|
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
|
* `NaN` matches `NaN`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to inspect.
|
|
* @param {...Array} [values] The arrays of values to exclude.
|
|
* @returns {Array} Returns the new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.difference([1, 2, 3], [4, 2]);
|
|
* // => [1, 3]
|
|
*/
|
|
var difference = restParam(function(array, values) {
|
|
return (isArray(array) || isArguments(array))
|
|
? baseDifference(array, baseFlatten(values, false, true))
|
|
: [];
|
|
});
|
|
|
|
return difference;
|
|
});
|