Creates an object composed of the inverted keys and values of `object`. If `object` contains duplicate values, subsequent values overwrite property assignments of previous values.
const object = { 'a': 1, 'b': 2, 'c': 1 }
invert(object)
// => { '1': 'c', '2': 'b' }
Name | Type | Attribute | Description |
---|---|---|---|
object | The object to invert. |
{ "comment": "/**\r\n * Creates an object composed of the inverted keys and values of `object`.\r\n * If `object` contains duplicate values, subsequent values overwrite\r\n * property assignments of previous values.\r\n *\r\n * @since 0.7.0\r\n * @category Object\r\n * @param {Object} object The object to invert.\r\n * @returns {Object} Returns the new inverted object.\r\n * @example\r\n *\r\n * const object = { 'a': 1, 'b': 2, 'c': 1 }\r\n *\r\n * invert(object)\r\n * // => { '1': 'c', '2': 'b' }\r\n */", "meta": { "range": [ 467, 613 ], "filename": "invert.js", "lineno": 17, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100003925", "name": "invert", "type": "FunctionDeclaration", "paramnames": [ "object" ] }, "vars": { "result": "invert~result", "": null } }, "description": "Creates an object composed of the inverted keys and values of `object`.\rIf `object` contains duplicate values, subsequent values overwrite\rproperty assignments of previous values.", "since": "0.7.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Object", "value": "Object" } ], "params": [ { "type": { "names": [ "Object" ] }, "description": "The object to invert.", "name": "object" } ], "returns": [ { "type": { "names": [ "Object" ] }, "description": "Returns the new inverted object." } ], "examples": [ "const object = { 'a': 1, 'b': 2, 'c': 1 }\r\rinvert(object)\r// => { '1': 'c', '2': 'b' }" ], "name": "invert", "longname": "invert", "kind": "function", "scope": "global", "___id": "T000002R000398", "___s": true, "filepath": "invert.js" }