Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

loadash pick property from object by different name

var arr = [
{"id":1,"name":"Name1","status":"active","account_id":"2KGGALS2353255"},
{"id":2,"name":"Name2","status":"active","account_id":"4ABCLS2353255"},
{"id":3,"name":"Name3","status":"active","account_id":"6LMNALS2353255"}
];

var result = arr.map(function(obj) {
  return {
    core: _.pick(obj, ['id', 'name']),
    extra: _.omit(obj, ['id', 'name'])
  };
});

console.log(result);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #loadash #pick #property #object
ADD COMMENT
Topic
Name
8+1 =