isNaN和Number.isNaN有什么区别?
isNaN('hello world'); // returns 'true'.
Number.isNaN('hello world'); // returns 'false发布于 2018-11-19 19:18:16
对于这种微妙之处来说,规范是一个很好的选择。isNaN试图将其参数转换为一个数字;而Number.isNaN没有,如果它的参数类型不是"number",则返回false。所以:
console.log(isNaN("%")); // true, coerced to number and result was NaN
console.log(Number.isNaN("%")); // false, not coerced
https://stackoverflow.com/questions/53381202
复制相似问题