From 9f3f0a76aa318138422fe05d0eecedb3930502cc Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 16 Apr 2015 20:07:48 -0700 Subject: [PATCH] Ensure `baseGet` returns `undefined` and not `null`. [closes #1136] --- lodash.src.js | 4 ++-- test/test.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 26b9c85c0..279df41e7 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2305,9 +2305,9 @@ length = path.length; while (object != null && ++index < length) { - var result = object = toObject(object)[path[index]]; + object = toObject(object)[path[index]]; } - return result; + return (index && index == length) ? object : undefined; } /** diff --git a/test/test.js b/test/test.js index 35367f035..2d32f8afc 100644 --- a/test/test.js +++ b/test/test.js @@ -13222,7 +13222,7 @@ }); test('`_.' + methodName + '` should return `undefined` if parts of `path` are missing', 2, function() { - var object = {}; + var object = { 'a': [, null] }; _.each(['a[1].b.c', ['a', '1', 'b', 'c']], function(path) { strictEqual(func(object, path), undefined);