Ensure _.toString produces the correct result for Object(-0).

This commit is contained in:
John-David Dalton
2015-10-28 07:29:20 -07:00
parent cd371ac66f
commit bc2adb208c
2 changed files with 11 additions and 8 deletions

View File

@@ -9760,15 +9760,12 @@
* @returns {string} Returns the string.
*/
function toString(value) {
// Preserve sign of `0`.
if (value === 0) {
return (1 / value) == INFINITY ? '0' : '-0';
}
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
return value == null ? '' : (value + '');
var result = value == null ? '' : (value + '');
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
}
/*------------------------------------------------------------------------*/