The collection to iterate over.
The function invoked per iteration.
Returns the array of grouped elements.
5.11.0
[[groupBy]], [[keyBy]]
const users = [
{ 'user': 'barney', 'age': 36, 'active': false },
{ 'user': 'fred', 'age': 40, 'active': true },
{ 'user': 'pebbles', 'age': 1, 'active': false }
]
partition(users, ({ active }) => active)
// => objects for [['fred'], ['barney', 'pebbles']]
Creates an array of elements split into two groups, the first of which contains elements
predicate
returns truthy for, the second of which contains elementspredicate
returns falsey for. The predicate is invoked with one argument: (value).