3-5编程练习
来源:3-11 编程练习
hy_wang
2017-12-20 22:53:58
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>数据类型之NaN</title> </head> <body> <script> var two=null; var one=10; var three="我是字符串"; var four="10"; var five; console.log(isNaN(two)); console.log(isNaN(one)); console.log(isNaN(three)); console.log(isNaN(five)); console.log(isNaN(four)); </script> </body> </html> 请问老师关于null为什么结果是false,他是一个空的 使用typeof(null)返回object,可是为什么他isNaN的返回是false?
1回答
你好,isNaN会先把内容转换为数字类型,null转换后为0,所以返回false。
祝学习愉快~