O'Reilly logo
  • Patrick S thinks this is interesting:

_.countBy. This function works similarly to _.groupBy, except that it returns an object with keys of the match criteria associated with its count, as shown in the following:

_.countBy(albums, function(a) { return a.genre });

//=> ...