From 618966c703f45f2409c274a644f224703c342165 Mon Sep 17 00:00:00 2001 From: Ming Beckwith Date: Thu, 2 Jan 2014 20:03:34 -0500 Subject: [PATCH] assign value to new arrays at creation in _.groupBy --- underscore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/underscore.js b/underscore.js index 7625e2461..0eb01e1b4 100644 --- a/underscore.js +++ b/underscore.js @@ -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