Skip to content
On this page

groupBy

Create an object consisting of keys created by applying predicate to the given array.

Example

groupBy([1, 2, 3, 4, 5], (x) => x % 2) // => { 0: [2, 4], 1: [1, 3, 5] }

Playground

const { groupBy } = require('rhodash')
groupBy([1, 2, 3, 4, 5], (x) => x % 2) // => { 0: [2, 4], 1: [1, 3, 5] }