This method is like `union` except that it accepts `iteratee` which is invoked for each element of each `arrays` to generate the criterion by which uniqueness is computed. Result values are chosen from the first array in which the value occurs. The iteratee is invoked with one argument: (value).
unionBy([2.1], [1.2, 2.3], Math.floor)
// => [2.1, 1.2]
Name | Type | Attribute | Description |
---|---|---|---|
arrays | The arrays to inspect. | ||
iteratee | The iteratee invoked per element. |
{ "comment": "/**\r\n * This method is like `union` except that it accepts `iteratee` which is\r\n * invoked for each element of each `arrays` to generate the criterion by\r\n * which uniqueness is computed. Result values are chosen from the first\r\n * array in which the value occurs. The iteratee is invoked with one argument:\r\n * (value).\r\n *\r\n * @since 4.0.0\r\n * @category Array\r\n * @param {...Array} [arrays] The arrays to inspect.\r\n * @param {Function} iteratee The iteratee invoked per element.\r\n * @returns {Array} Returns the new array of combined values.\r\n * @see difference, union, unionWith, without, xor, xorBy\r\n * @example\r\n *\r\n * unionBy([2.1], [1.2, 2.3], Math.floor)\r\n * // => [2.1, 1.2]\r\n */", "meta": { "range": [ 880, 1090 ], "filename": "unionBy.js", "lineno": 24, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100011118", "name": "unionBy", "type": "FunctionDeclaration", "paramnames": [ "arrays" ] }, "vars": { "iteratee": "unionBy~iteratee" } }, "description": "This method is like `union` except that it accepts `iteratee` which is\rinvoked for each element of each `arrays` to generate the criterion by\rwhich uniqueness is computed. Result values are chosen from the first\rarray in which the value occurs. The iteratee is invoked with one argument:\r(value).", "since": "4.0.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Array", "value": "Array" } ], "params": [ { "type": { "names": [ "Array" ] }, "optional": true, "variable": true, "description": "The arrays to inspect.", "name": "arrays" }, { "type": { "names": [ "function" ] }, "description": "The iteratee invoked per element.", "name": "iteratee" } ], "returns": [ { "type": { "names": [ "Array" ] }, "description": "Returns the new array of combined values." } ], "see": [ "difference, union, unionWith, without, xor, xorBy" ], "examples": [ "unionBy([2.1], [1.2, 2.3], Math.floor)\r// => [2.1, 1.2]" ], "name": "unionBy", "longname": "unionBy", "kind": "function", "scope": "global", "___id": "T000002R001009", "___s": true, "filepath": "unionBy.js" }