当前位置:网站首页>(JS)isNaN()方法判断undefined为true的原因
(JS)isNaN()方法判断undefined为true的原因
2022-06-29 09:57:00 【不愿透露姓名的余菜鸟】
使用isNaN()判断是不是NaN时,此方法会使用Number()方法做一个转换,任何非数字都会被强制类型转换,undefined被转换后为NaN,所以显示true
console.log(isNaN(undefined)) //true
isNaN()转换时除了null和数组类型会被转为数字0之外,其余非数字类型的皆会被转为NaN
字符串
console.log(isNaN("qigeyu")) //true
对象
console.log(isNaN({
})) //true
边栏推荐
猜你喜欢

CLR via C reading notes - loading and AppDomain

He was in '98. I can't play with him

AQS之BlockingQueue源码解析

BUUCTF--reverse2

Daily question brushing record (VII)

【评论送书】适合初学者的 6 个有趣的 R 语言项目

UserWarning: Usage of dash-separated ‘script-dir‘ will not be supported in future versions. note

Fully understand the volatile keyword

《Datawhale推荐系统教程》来了!

SQL Server 数据库的连接查询
随机推荐
Detailed explanation of handwritten numeral recognition based on support vector machine (Matlab GUI code, providing handwriting pad)
有人遇到FlinkCdc同步MySQL时候出现的这个问题吗?
[200 opencv routines] 214 Detailed explanation of drawing ellipse parameters
He was in '98. I can't play with him
加密市场接连爆雷,Celsius能避免破产吗?
Excel date and number format processing
请问,flink sql 批任务,两表或多表join(inner join 或 outer join
WinForm uses zxing to generate QR code
Getting started with the lvgl Library - Animation
任职 22 年,PowerShell 之父将从微软离职:曾因开发 PowerShell 被微软降级过
【Rust每周一库】Tokei - 统计代码行数等信息的实用工具
X-Frame-Options(点击劫持) 网页劫持漏洞
真正的测试 =“半个产品+半个开发”?
&和&&的区别
Comprehensive understanding of synchronized
Alibaba cloud server is installed and configured with redis. Remote access is unavailable
Reading notes of CLR via C -clr boarding and AppDomain
Luoqingqi: has high-end household appliances become a red sea? Casati took the lead in breaking the game
BUUCTF RE-easyre
Common motor classification and driving principle animation [easy to understand]