var arr = [{
key: 1,
name: 2,
job: 3
}, {
key: 1,
name: 22,
job: 33
}, {
key: 2,
name: 222,
job: 333
}, {
key: 2,
name: 2222,
job: 3333
}];
The arr array has multiple fields, and I want to merge them based on the same property of the key field.
the final result you want to achieve, such as arr2
arr2 = [{
key: 1,
info: [{
name: 2,
job: 3
}, {
name: 22,
job: 33
}]
}, {
key: 2,
info: [{
name: 222,
job: 333
}, {
name: 2222,
job: 3333
}]
}];