diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-25 18:20:58 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-25 18:20:58 -0700 |
commit | e0053d0115e7028a990aa3d189209c3cc22919c6 (patch) | |
tree | 975542763ed8baf7b94db7e7c07beed77d02b3f6 | |
parent | 866039dc1f1c880399d3819a1194350d78c12a33 (diff) |
detect NaN as a number
-rw-r--r-- | src/utility.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/utility.js b/src/utility.js index 62adb807..bec0eb8f 100644 --- a/src/utility.js +++ b/src/utility.js @@ -222,8 +222,8 @@ function mergeInto(obj, other) { } function isNumber(x) { - // XXX this does not handle 0xabc123 etc - return x == parseFloat(x) || (typeof x == 'string' && x.match(/^-?\d+$/)); + // XXX this does not handle 0xabc123 etc. We should likely also do x == parseInt(x) (which handles that), and remove hack |// handle 0x... as well| + return x == parseFloat(x) || (typeof x == 'string' && x.match(/^-?\d+$/)) || x === 'NaN'; } function isArray(x) { |