For example, old data:
var old = [
{
id: 1,
name: 'css',
type: 'html'
},
{
id: 2,
name: 'css',
type: 'html'
},
{
id: 3,
name: 'javacript',
type: 'code'
},
{
id: 4,
name: 'javacript',
type: 'code'
}
]
What you want var new = [
{
id: [1,2],
name: 'css',
type: 'html'
},
{
id: [3,4],
name: 'javacript',
type: 'code'
},
]
I hope to merge objects with the same name and put the corresponding ids into an array
From the array
old
belowGet
new
Achieved