Object.groupBy replaces your reduce
JavaScriptGrouping an array by a key was the single most common reason to reach for `reduce`. It is now built in, in both object and Map flavours. `Map.groupBy` is the one you usually want, because it preserves key types instead of coercing them to strings.
const byStatus = Object.groupBy(orders, (o) => o.status);
// { open: [...], paid: [...] }
// keys stay as real values, not stringified
const byUser = Map.groupBy(orders, (o) => o.userId);GotchaObject.groupBy returns a null-prototype object, so `hasOwnProperty` and friends are not on it.