📜  loadash 从不同名称的对象中选择属性 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:34.252000             🧑  作者: Mango

代码示例1
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);