Jake O.’s Post

In real codebases, I still see data grouping done with long reduce blocks or a Lodash import. Object.groupBy standardizes this into a single native call, which can improve readability and help trim dependencies. The trade-off is support: you may still need a polyfill or fallback for older runtimes, so check your target browsers and Node versions. Are you planning to adopt Object.groupBy now, or keep a utility layer for consistency across environments? #javascript #webdev #frontend #typescript #performance

  • No alternative text description for this image

If you can't guarantee support for groupBy then just wrap the reduce in a function "groupByRole" and move it to the bottom of the file (hoist it). You can/should leverage hoisting to help keep files reading from most declarative to increasingly more imperative, preserving "immidiate comprehension" even when lacking built in or third party utils.

Like
Reply

I think lodash is a good way to go, taking into account es moodules support in lodash. As soon as native es methods become widely adopted (baseline) we can switch step by step our codebases, just to reduce bundle size.

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories