Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #1394 from mcbex/master
Browse files Browse the repository at this point in the history
assign value to new arrays at creation in _.groupBy
  • Loading branch information
michaelficarra committed Jan 3, 2014
2 parents d645a47 + 618966c commit 754c312
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion underscore.js
Expand Up @@ -356,7 +356,7 @@
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
_.groupBy = group(function(result, key, value) {
(_.has(result, key) ? result[key] : (result[key] = [])).push(value);
_.has(result, key) ? result[key].push(value) : result[key] = [value];
});

// Indexes the object's values by a criterion, similar to `groupBy`, but for
Expand Down

0 comments on commit 754c312

Please sign in to comment.