您的位置:首页 > Web前端 > JavaScript

[Javascript] Identify and Deal with NaN in JavaScript

2017-02-06 02:46 525 查看
Dealing with the special
NaN
value can be tricky in JavaScript. It behaves like a number and not a number at the same time. This lesson explains how to identify it using the
isNaN
function or the
Number.isNaN
method.

Number.isNaN = Number.isNaN  || function(x) {x !== x}


Number.isNaN(NaN) // true
Number.isNaN("JS") // false
Number.isNaN("") // false
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐