我有一个数组:
let docArray = [
{ documentID: 304717110, doublettenID: 111, done: true },
{ documentID: 304717110, doublettenID: 222, done: true },
{ documentID: 304717110, doublettenID: 333, done: true },
{ documentID: 304717110, doublettenID: 444, done: true },
{ documentID: 304717110, doublettenID: 555, done: true },
{ documentID: 304717110, doublettenID: 666, done: true },
{ documentID: 304862280, doublettenID: null, done: true },
{ documentID: 304862281, doublettenID: null, done: true },
{ documentID: 304933685, doublettenID: null, done: true },
{ documentID: 304933871, doublettenID: null, done: true },
{ documentID: 304933870, doublettenID: null, done: true },
{ documentID: 304862282, doublettenID: null, done: true }
]
我想按 documentID 分组,并为每个不同的 documentID 创建一个对象,并将“doublettenID”字段值推送到每个对象的数组中。我怎样才能轻松做到这一点?
呼如林
红糖糍粑
相关分类