From 2b2c8e6b82a84c9bea40908d8f702b478c53ec5a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 18 Jul 2013 09:09:46 -0700 Subject: [PATCH] Ensure `_.zipObject` skips falsey elements in a given two dimensional array. Former-commit-id: 31ce7e65aee98cbed477276ae9115b33fd10c6ea --- lodash.js | 2 +- test/test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 3d3ab18fe..e84e66e01 100644 --- a/lodash.js +++ b/lodash.js @@ -4561,7 +4561,7 @@ var key = keys[index]; if (values) { result[key] = values[index]; - } else { + } else if (key) { result[key[0]] = key[1]; } } diff --git a/test/test.js b/test/test.js index c03a763b3..704d9bfeb 100644 --- a/test/test.js +++ b/test/test.js @@ -3576,6 +3576,17 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.zipObject'); + + (function() { + test('should skip falsey elements in a given two dimensional array', function() { + var actual = _.zipObject([['a', 1], ['b', 2]].concat(falsey)); + deepEqual(actual, { 'a': 1, 'b': 2 }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash(...).shift'); (function() {