Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var baseFlatten = require('../internal/baseFlatten'),
2
baseUniq = require('../internal/baseUniq'),
3
restParam = require('../function/restParam');
4
5
/**
6
* Creates an array of unique values, in order, from all of the provided arrays
7
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
8
* for equality comparisons.
9
*
10
* @static
11
* @memberOf _
12
* @category Array
13
* @param {...Array} [arrays] The arrays to inspect.
14
* @returns {Array} Returns the new array of combined values.
15
* @example
16
*
17
* _.union([1, 2], [4, 2], [2, 1]);
18
* // => [1, 2, 4]
19
*/
20
var union = restParam(function(arrays) {
21
return baseUniq(baseFlatten(arrays, false, true));
22
});
23
24
module.exports = union;
25
26