javascript - Use invert in an object with many entries -


i trying reverse keys/values.

so , trying like:

var _ = require('underscore');  var myobj = [      {'name': 'mike', 'number' : 'b1' , 'level' : 0 },     {'name': 'tom', 'number' : 'b2' , 'level' : 0 } ];   object.keys(myobj).foreach(function(k) {      _.invert(myobj[k]); });    console.log(myobj); 

so, want receive:

{'mike': 'name', 'b1' : 'number' , '0' : level }, {'tom': 'name', 'b2' : 'number' , '0' : level } 

but above gives me again initial object.

this should want:

var result = _.map(myobj, _.invert); 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -