小编典典

使用 lodash 将对象转换为数组

all

object我怎样才能array用 lodash将一个大的转换为?

var obj = {
  22: {name:"John", id:22, friends:[5,31,55], works:{books:[], films:[],}
  12: {name:"Ivan", id:12, friends:[2,44,12], works:{books:[], films:[],}
}

// transform to 
var arr = [{name:"John", id:22...},{name:"Ivan", id:12...}]

阅读 94

收藏
2022-07-06

共1个答案

小编典典

你可以做

var arr = _.values(obj);

有关文档,请参见此处。

2022-07-06