3 ms·
It is indeed something that you often roll your own, write an utility function for, or include libraries like lodash for. JS standard library is notoriously de
by moritzwarhier 3y ago
It is indeed something that you often roll your own, write an utility function for, or include libraries like lodash for.
JS standard library is notoriously deficient.
This is a good addition in my view too, especially including Map.
When dealing with DB/API results, one can of course always say that such grouping in the client is an anti-pattern.
But in reality it can be reasonable and useful.
If you write one-off algorithms in JS to transform small amounts of data on the client, you probably habe done this.
And even for data-heavy applications, it could prove to be a performance benefit for functions that use Map instances during computation.
Though that's just wishful thinking until the runtime developers choose to optimize these functions, if possible.
- pmontra 3y ago> When dealing with DB/API results, one can of course always say that such grouping in the client is an anti-pattern. It depends on how many data you're working on. This groupBy is useful for filters in data tables. If you have to download a zillion of records and filter them, client side filtering is a bad idea. If you have a few thousands of them, it could possibly be the faster solution overall.
- moritzwarhier 3y agoExactly.