diff --git a/lodash.src.js b/lodash.src.js index 9aba6844a..48671c5a1 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -10000,6 +10000,8 @@ * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) */ function pairs(object) { + object = toObject(object); + var index = -1, props = keys(object), length = props.length, diff --git a/test/test.js b/test/test.js index ffd838b51..82f4a8edf 100644 --- a/test/test.js +++ b/test/test.js @@ -11813,6 +11813,12 @@ var object = { '0': 'a', '1': 'b', 'length': 2 }; deepEqual(_.pairs(object), [['0', 'a'], ['1', 'b'], ['length', 2]]); }); + + test('should work with strings', 2, function() { + _.each(['xo', Object('xo')], function(string) { + deepEqual(_.pairs(string), [['0', 'x'], ['1', 'o']]); + }); + }); }()); /*--------------------------------------------------------------------------*/