In the above screenshot, I have applied a GroupBy setting on a SharePoint View. I needed the same exact values in my application through JSOM. However, all of the online examples, that I came across, were of retrieving all the ListItems of a SharePoint List. You can either retrieve all the items at once or in batches, but there seems to be no provision of applying grouping or aggregation on the ListItems through code!
Somehow, I wasn’t convinced of this and was vehemently against this idea of pulling all the data on client-side first, thereafter applying grouping and aggregations.