mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Ensure _.toString produces the correct result for Object(-0).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user