_.isNaN
Checks if a value is NaN.
- // Underscore/Lodash
- console.log(_.isNaN(NaN))
- // output: true
- // Native
- console.log(isNaN(NaN))
- // output: true
- // ES6
- console.log(Number.isNaN(NaN))
- // output: true
MDN:
In comparison to the global
isNaN()
function,Number.isNaN()
doesn't suffer the problem of forcefully converting the parameter to a number. This means it is now safe to pass values that would normally convert toNaN
, but aren't actually the same value asNaN
. This also means that only values of the type number, that are alsoNaN
, return true. Number.isNaN()
Voice from the Lodash author:
Lodash's
_.isNaN
is equiv to ES6Number.isNaN
which is different than the globalisNaN
.—- jdalton
Browser Support for isNaN
✔ | ✔ | 1.0 ✔ | ✔ | ✔ | ✔ |
Browser Support for Number.isNaN
25.0 ✔ | ✔ | 15.0 ✔ | ✖ | ✔ | 9.0 ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .