JSworkinges2024

Object.groupBy and Map.groupBy

Bucket an array in one call.

Object.groupBy and Map.groupBy turn a flat array into named buckets using a callback — no reduce boilerplate, no accidental prototype pollution, no manual array initialisation.

Group by a category field

JSintro
Press Run to execute

The two keys peripherals and displays appear in first-seen order, and each bucket holds its items in input order (Keyboard, Mouse, Webcam) — one call replaced the whole acc[key] ??= [] reduce.