From 7bc5a501c44961d1133d7920d98d44b4ee2f6694 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 21 Aug 2015 18:35:31 -0700 Subject: [PATCH] Remove explicit `Object` coercion in `_.keysIn`. --- lodash.js | 4 +--- test/test.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lodash.js b/lodash.js index c2d076906..2d6fd1c95 100644 --- a/lodash.js +++ b/lodash.js @@ -3877,7 +3877,7 @@ * @returns {Array} Returns the initialized array of property names. */ function initKeys(object) { - var length = object.length; + var length = object ? object.length : 0; length = (length && isLength(length) && (isArray(object) || isArguments(object) || isString(object)) && length) || 0; @@ -9171,8 +9171,6 @@ * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { - object = Object(object); - var index = -1, isProto = isPrototype(object), props = baseKeysIn(object), diff --git a/test/test.js b/test/test.js index 9a28c9631..341836677 100644 --- a/test/test.js +++ b/test/test.js @@ -8773,10 +8773,10 @@ deepEqual(func(array).sort(), ['0', '1', '2']); }); - test('`_.' + methodName + '` should coerce nullish values to objects', 2, function() { + test('`_.' + methodName + '` should not coerce nullish values to objects', 2, function() { objectProto.a = 1; _.each([null, undefined], function(value) { - deepEqual(func(value), isKeys ? [] : ['a']); + deepEqual(func(value), []); }); delete objectProto.a; });