Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

reverse keys and values in object javascript

 var object = { 'a': 1, 'b': 2, 'c': 1 };
//This uses the package lodash

  _.invert(object);
  // => { '1': 'c', '2': 'b' }

  // with `multiValue`
  _.invert(object, true);
  // => { '1': ['a', 'c'], '2': ['b'] }

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #reverse #keys #values #object #javascript
ADD COMMENT
Topic
Name
5+2 =