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
Post a Comment