当前位置:网站首页>js中isNaN和Number.isNaN的区别
js中isNaN和Number.isNaN的区别
2022-07-27 05:03:00 【weixin_46051260】
1)isNaN
- 为了判断一个计算结果或者变量的值是否NaN
- isNaN(value):value表示检测的值
- 判断过程:首先进行类型检测,如果传入的参数不是数值类型,第二步将传入的参数转为数值类型,然后在进行是否为NaN的判断
console.log(isNaN(NaN));//true
console.log(isNaN(true));//false
console.log(isNaN('aaa'));//true
console.log(isNaN(null));//false
console.log(isNaN(''));//false
console.log(isNaN(undefined));//true
2)Number.isNaN的判断过程:首先进行类型检测,如果传入的参数不是数值类型,直接返回false如果判断是数值类型,然后用isNaN的方式进行判断
console.log(Number.isNaN(NaN));//true
console.log(Number.isNaN(true));//false
console.log(Number.isNaN('aaa'));//false
console.log(Number.isNaN(null));//false
console.log(Number.isNaN(123));//false
console.log(Number.isNaN(undefined));//false
边栏推荐
猜你喜欢

创建项目 实现登录注册,生成jwt,发送验证码

c语言字符串函数下:strcmp、strncpy、strncat、strncmp、strstr、strtok、strerror

Source code of document type full-text retrieval knowledge base management system

用户的管理-限制

Li Hongyi machine learning team learning punch in activity day02 --- return

初识C语言——初识指针

努力进化中_我的第一篇csdn博客

flask项目配置

后台频道组管理功能实现

The concept of cloud native application and 15 characteristics of cloud native application
随机推荐
分享一道关于变量的选择题(内含全局变量、局部变量、变量的作用域、生命周期知识点)
C语言指针入门详细介绍
C语言入门介绍
自己动手做一个爬虫项目
Promise的理解,以及它的实例方法
C language string function: strlen, strcpy, strcat
Sparse array → saving and continuation of Gobang
Localdatetime and zoneddatetime
上传七牛云的方法
md5 密码加密
Redis transaction
时间复杂度与空间复杂度
C language string function: StrCmp, strncpy, strncat, strncmp, strstr, strtok, strError
c语言字符串函数上:strlen、strcpy、strcat
Time complexity and space complexity
商品图片的管理
Share a multiple-choice question about the process of program compilation (including a brief discussion on the compilation process, the formation and merging process of symbol tables)
Differences and examples between internal classes and static internal classes
Introduction to C language pointer
Flask框架创建项目初期总结