The collection to iterate over.
The iteratee to transform keys.
Returns the composed aggregate object.
5.7.0
const users = [
{ 'user': 'barney', 'active': true },
{ 'user': 'betty', 'active': true },
{ 'user': 'fred', 'active': false }
]
countBy(users, value => value.active);
// => { 'true': 2, 'false': 1 }
Creates an object composed of keys generated from the results of running each element of
collection
thruiteratee
. The corresponding value of each key is the number of times the key was returned byiteratee
. The iteratee is invoked with one argument: (value).