From 7c5e03285372e3720e7a397177d546e42d106c54 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 8 Jan 2016 11:47:17 -0800 Subject: [PATCH] Simplify `isNumber`. --- lodash.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lodash.js b/lodash.js index 868562ded..8e9a78985 100644 --- a/lodash.js +++ b/lodash.js @@ -10233,15 +10233,12 @@ * // => 3 */ function toNumber(value) { - if (!value) { - return value === 0 ? value : +value; - } if (isObject(value)) { var other = isFunction(value.valueOf) ? value.valueOf() : value; value = isObject(other) ? (other + '') : other; } - if (typeof value == 'number' || !isString(value)) { - return +value; + if (typeof value != 'string') { + return value === 0 ? value : +value; } value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value);