Standard built-ins
Map.groupBy()
Group iterable values by callback-produced keys. The callback receives item and index; each group is an array containing original values, not deep copies.
Formal Syntax & Structure
javascript syntaxjavascript
Map.groupBy(items, callback)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| items | Iterable | Values to group. |
| callback | Function | Receives item and index; returns key. |
Return Value
Map
Keys mapped to group arrays.
Working Example
Example Snippetjavascript
const m=Map.groupBy([1,2,3],n=>n%2);console.log(JSON.stringify(m.get(1)));