SOURCE

var array =[
   {a:'王五',b:0},
   {a:'张三',b:1},
   {a:'张三',b:2},
   {a:'李四',b:3},
   {a:'李四',b:4},
   {a:'张六',b:5},
   {a:'王五',b:6}
 ]
console.log('源数据:', array)
var newArray = []
array.forEach(e =>{
    var temp = newArray.find(r => r.a ===e.a)
    if (temp == null){
        e.list = [e.b]
        newArray.push(e)
        return
    } 
    if (temp.list.find(res =>res.b === e.b)== null){
        temp.list.push(e.b)
    }
})
console.log('newArray:',newArray)
console 命令行工具 X clear

                    
>
console