For a basic demo of _.countBy I just made an array of objects, and used countBy to make an object of true, and false properties that is a count of how many objects meet the condition that I defined in the method that I gave it, along with the array of objects.
So it seems that this can be a useful method to be aware of to quickly find out a count of how many elements in an array meet a given set of conditions, and how many do not. I am not aware of anything in corejs that does this, so thins may be one of the methods in lodash to which there is not a direct native equivalent.
One of the advantages of using may of these lodash methods is that shorthands like the ‘_.property’ iteratee shorthand can be used to get an object of keys where each key is a word length, and each value is how many times a word of that length appears in the collection.
The following will give the same result when it comes to giving a method rather than using the property shorthand.
This _.countBy method might come in handy for some situations in which I quickly want to make an object that has keys, and values that are the result of some kind of condition. This makes _.countBy one of the methods in lodash to be aware of to make quick work of any kind of situation where it would come in handy.