Groups the source by a key selector.
Type of items in the source.
Type of the key.
Key selector function.
Collector that groups the source by a key selector.
const result = groupBy<number, string>((x) => x % 2 === 0 ? "even" : "odd")([1, 2, 3, 4]);console.log(result);// Map {// 'odd' => [1, 3],// 'even' => [2, 4],// } Copy
const result = groupBy<number, string>((x) => x % 2 === 0 ? "even" : "odd")([1, 2, 3, 4]);console.log(result);// Map {// 'odd' => [1, 3],// 'even' => [2, 4],// }
Groups the source by a key selector.