diff --git a/lodash.js b/lodash.js index e990c2387..820fd0340 100644 --- a/lodash.js +++ b/lodash.js @@ -3999,7 +3999,7 @@ * // => [10, 20] */ function pullAt(array) { - return basePullAt(array, baseFlatten(arguments, false, false, 1)); + return basePullAt(array || [], baseFlatten(arguments, false, false, 1)); } /** diff --git a/test/test.js b/test/test.js index 63ec80ff2..fce0dd4e9 100644 --- a/test/test.js +++ b/test/test.js @@ -953,6 +953,18 @@ deepEqual(actual, ['d', 'a', 'c']); }); + test('should work with a falsey `array` argument when keys are provided', 1, function() { + var expected = _.map(falsey, _.constant([undefined, undefined])); + + var actual = _.map(falsey, function(value) { + try { + return _.at(value, 0, 1); + } catch(e) {} + }); + + deepEqual(actual, expected); + }); + test('should work with an `arguments` object for `collection`', 1, function() { var actual = _.at(args, [2, 0]); deepEqual(actual, ['c', 'a']); @@ -9184,6 +9196,18 @@ deepEqual(actual, ['d', 'a', 'c']); }); + test('should work with a falsey `array` argument when keys are provided', 1, function() { + var expected = _.map(falsey, _.constant([undefined, undefined])); + + var actual = _.map(falsey, function(value) { + try { + return _.pullAt(value, 0, 1); + } catch(e) {} + }); + + deepEqual(actual, expected); + }); + test('should ignore non-index values', 2, function() { var array = ['a', 'b', 'c'], clone = array.slice();