Example 1 — Official: Group by Function
Pass an iteratee that returns the group key for each value.
_.groupBy([1.3, 2.1, 2.4], function (num) {
return Math.floor(num);
});
// → { 1: [1.3], 2: [2.1, 2.4] } How It Works
- Iteratee.
Math.floorturns each number into an integer key. - First key.
1.3→1→ starts array[1.3]. - Shared key.
2.1and2.4both map to2. - Shape. Result is an object of arrays, not a nested array list.

