Lodash invert method
语法
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.
参数
object (Object) − The object to invert.
输出
(Object) − Returns the new inverted object.
实例
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
输出