js 技巧

[data group ]

https://stackoverflow.com/questions/42081375/lodash-group-and-populate-arrays?fbclid=IwAR2y0MMs5OxNxlzCoxer2g7TfC5qeh5fH13Ms8l5twpoLYC-rsGqz5NxnHo

[
    { "birthdate": "1993", "name": "Ben" },
    { "birthdate": "1994", "name": "John" },
    { "birthdate": "1995", "name": "Larry" },
    { "birthdate": "1995", "name": "Nicole" },
    { "birthdate": "1996", "name": "Jane" },
    { "birthdate": "1996", "name": "Janet" },
    { "birthdate": "1996", "name": "Dora" },
]
to

[
    { "birthdate": "1993", "names": [ “Ben” ] }, 
    { "birthdate": "1994", "names": [ “John”] },
    { "birthdate": "1995", "names": [ “Larry”, “Nicole” ] }, 
    { "birthdate": "1996", "names": [ “Jane”, “Janet”, “Dora” ] }        
]