๐—ง๐—ต๐—ฒ ๐—˜๐—ฎ๐—Œ๐˜† ๐—ช๐—ฎ๐˜† ๐—ง๐—ผ ๐—œ๐—ป๐—ฑ๐—ฒ๐˜… ๐—ฎ๐—ป๐—ฑ ๐—ข๐—ฟ๐—ด๐—ฎ๐—ป๐—ถ๐˜‡๐—ฒ ๐——๐—ฎ๐˜๐—ฎ ๐—ถ๐—ป ๐—๐—ฎ๐˜ƒ๐—ฎ๐—ฆ๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜ You need to organize arrays of objects. You can use reduce to do this. But reduce can make code complex and hard to understand.

Good news: there's a simpler way to do this using Object.groupBy and Map.groupBy methods.

Why group data?

Here's an example: You have a list of products. You want to group them by category. You can use Object.groupBy to do this:

const products = [
  { name: "iPhone", category: "electronics", price: 5000 },
  { name: "Laptop", category: "electronics", price: 3000 },
  { name: "T-shirt", category: "clothing", price: 50 },
  { name: "Pants", category: "clothing", price: 120 },
];
const productsByCategory = Object.groupBy(products, (product) => product.category);

Map.groupBy handles cases where the key is not a string. 
- It preserves the original type of the key.
- It avoids automatic conversions and ambiguities.

These new grouping methods simplify your development routine. 
- They make your code leaner and more expressive.
- They are widely supported in modern browsers.

Source: https://dev.to/sucodelarangela/groupby-in-javascript-the-easy-way-to-index-and-organize-data-53op