- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - invert method
Syntax
_.invert(object)
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.
Arguments
object (Object) − The object to invert.
Output
(Object) − Returns the new inverted object.
Example
var _ = require('lodash'); var object = { 'a': 1, 'b': 2, 'c': 1 }; var result = _.invert(object); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
{ '1': 'c', '2': 'b' }
lodash_object.htm
Advertisements
To Continue Learning Please Login
Login with Google