diff --git a/lodash.js b/lodash.js index 47a2ab868..dea470910 100644 --- a/lodash.js +++ b/lodash.js @@ -4230,6 +4230,10 @@ if (typeof value == 'string') { return value; } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } if (isSymbol(value)) { return symbolToString ? symbolToString.call(value) : ''; } diff --git a/test/test.js b/test/test.js index 5dd4e08f1..7b6595197 100644 --- a/test/test.js +++ b/test/test.js @@ -23714,6 +23714,13 @@ assert.deepEqual(actual, expected); }); + QUnit.test('should preserve the sign of `0` in an array', function(assert) { + assert.expect(1); + + var values = [-0, Object(-0), 0, Object(0)]; + assert.deepEqual(_.toString(values), '-0,-0,0,0'); + }); + QUnit.test('should not error on symbols', function(assert) { assert.expect(1); @@ -23729,6 +23736,21 @@ } }); + QUnit.test('should not error on an array of symbols', function(assert) { + assert.expect(1); + + if (Symbol) { + try { + assert.strictEqual(_.toString([symbol]), 'Symbol(a)'); + } catch (e) { + assert.ok(false, e.message); + } + } + else { + skipAssert(assert); + } + }); + QUnit.test('should return the `toString` result of the wrapped value', function(assert) { assert.expect(1);