How to group an array of objects by key How to group an array of objects by key javascript javascript