当前位置:网站首页>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>
边栏推荐
- [hcsd celebrity live broadcast] teach the interview tips of big companies in person - brief notes
- MySQL中, 如何查询某一天, 某一月, 某一年的数据
- PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
- laravel中将session由文件保存改为数据库保存
- Tragedy caused by deleting the console statement
- AE learning 01: AE complete project summary
- 无法将“pip”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
- 分步式監控平臺zabbix
- Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
- 华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
猜你喜欢
【C 语言】 题集 of Ⅹ
What about the pointer in neural network C language
You Yuxi, coming!
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
Talk about the cloud deployment of local projects created by SAP IRPA studio
SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
Continuous creation depends on it!
Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
Power of leetcode-231-2
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
随机推荐
【Android -- 数据存储】使用 SQLite 存储数据
Unity3d click events added to 3D objects in the scene
Shipping companies' AI products are mature, standardized and applied on a large scale. CIMC, the global leader in port and shipping AI / container AI, has built a benchmark for international shipping
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
Asyncio concept and usage
如何在shell中实现 backspace
What is the difference between IP address and physical address
Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
Laravel5.1 路由 -路由分组
Shader_ Animation sequence frame
Migration and reprint
How does geojson data merge the boundaries of regions?
Particle effect for ugui
hellogolang
The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
ThinkPHP URL 路由简介
Description of vs common shortcut keys
SPI master RX time out interrupt
【知识小结】PHP使用svn笔记总结
一个普通人除了去工厂上班赚钱,还能干什么工作?