当前位置:网站首页>JS中null NaN undefined这三个值有什么区别
JS中null NaN undefined这三个值有什么区别
2022-07-07 14:15:00 【Vayne的胖虎子】
我们在JS数据类型中肯定会遇到比较陌生的面孔,比如NaN和undefined,对于null我们在Java中就早早接触过,那么我们来通过代码看一下这三个东西有什么关系和区别呢?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>null NaN undefined这三个值有什么区别</title>
</head>
<body>
<script type="text/javascript">
// == 是等同运算符
alert(1 == true); // true
alert(1 === true); // false
// null NaN undefined 数据类型不一致.
alert(typeof null); // "object"
alert(typeof NaN); // "number"
alert(typeof undefined); // "undefined"
// null和undefined可以等同.
alert(null == NaN); // false
alert(null == undefined); // true
alert(undefined == NaN); // false
// 在JS当中有两个比较特殊的运算符
// ==(等同运算符:只判断值是否相等)
// ===(全等运算符:既判断值是否相等,又判断数据类型是否相等)
alert(null === NaN); // false
alert(null === undefined); // false
alert(undefined === NaN); // false
</script>
</body>
</html>
边栏推荐
- 喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
- Particle effect for ugui
- The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
- Leetcode-136- number that appears only once (solve with XOR)
- 星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
- Wireless sensor networks -- ZigBee and 6LoWPAN
- Migration and reprint
- 强化实时数据管理,英方软件助力医保平台安全建设
- Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!
- Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
猜你喜欢
强化实时数据管理,英方软件助力医保平台安全建设
Unity3D_ Class fishing project, bullet rebound effect is achieved
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
What are compiled languages and interpreted languages?
Xcode Revoke certificate
Tragedy caused by deleting the console statement
Leetcode-231-2的幂
Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
You Yuxi, coming!
Numpy --- basic learning notes
随机推荐
Markdown formula editing tutorial
spark调优(三):持久化减少二次查询
laravel构造函数和中间件执行顺序问题
markdown公式编辑教程
MySQL数据库基本操作-DQL-基本查询
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
【Vulnhub靶场】THALES:1
PHP has its own filtering and escape functions
JS 模块化
Xcode Revoke certificate
Shader_ Animation sequence frame
Logback logging framework third-party jar package is available for free
torch.numel作用
分类模型评价标准(performance measure)
一个普通人除了去工厂上班赚钱,还能干什么工作?
[excelexport], Excel to Lua, JSON, XML development tool
Is it reliable to open an account on Tongda letter with your mobile phone? Is there any potential safety hazard in such stock speculation
Laravel service provider instance tutorial - create a service provider test instance
Power of leetcode-231-2
Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()