SOURCE

let a = [
    { countp: 1, detp: "ZS" },
    { countp: 1, detp: "PP" },
    { countp: 1, detp: "ZS" },
    { countp: 1, detp: "PP" },
    { countp: 1, detp: "WQ" },
    { countp: 10, detp: "PP" },
    { countp: 10, detp: "WQ" },
    { countp: 6, detp: "MM" }
];
let obj={}
a.reduce(function(total, item, currentIndex, arr){
        let key = 'count' + item.detp
    if(!obj[key]){
        obj[key]=item.countp
    }else{
        obj[key]=obj[key]+item.countp
    }
})
// _.groupBy(a,function(item){
//     let key = 'count' + item.detp
//     if(!obj[key]){
//         obj[key]=item.countp
//     }else{
//         obj[key]=obj[key]+item.countp
//     }
// })
console.log(obj)
console 命令行工具 X clear

                    
>
console