mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
in groupBy, also pass index to iterator.
This commit is contained in:
@@ -254,8 +254,8 @@
|
||||
// Groups the object's values by a criterion produced by an iterator
|
||||
_.groupBy = function(obj, iterator) {
|
||||
var result = {};
|
||||
each(obj, function(value) {
|
||||
var key = iterator(value);
|
||||
each(obj, function(value, index) {
|
||||
var key = iterator(value, index);
|
||||
(result[key] || (result[key] = [])).push(value)
|
||||
});
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user