js数组重组
现在有一个数组类似于
var a=[{name:"May",age:12,id:1},{name:"Jone",age:13,id:5},{name:"May",age:15,id:6}];
要把所有name相同的对象重组，大概成为这样的数组
var b = [{
```
name: "May",
list: [{
    name: "May",
    age: 12,
    id: 1
}, {
    name: "May": age: 15,
    id: 6
}]
```
}, {
```
name: "Jone",
list: [{
    name: "Jone",
    age: 13,
    id: 5
}]
```
}]
```
const a = [{ name: "May", age: 12, id: 1 }, { name: "Jone", age: 13, id: 5 }, { name: "May", age: 15, id: 6 }]

let result = Object.values(a.reduce((m, n) => {
    if (!m[n.name]) {
        m[n.name] = {name: n.name, list: []}
    }
    m[n.name].list.push(n)
    return m
}, {}))

console.log(result)
```