当前位置:网站首页>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>
边栏推荐
- SPI master rx time out中断
- Asyncio concept and usage
- Talk about the cloud deployment of local projects created by SAP IRPA studio
- 无法将“pip”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
- laravel构造函数和中间件执行顺序问题
- Unity3D_ Class fishing project, control the distance between collision walls to adapt to different models
- 喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
- Use moviepy Editor clips videos and intercepts video clips in batches
- Bidding announcement: Panjin people's Hospital Panjin hospital database maintenance project
- How to implement backspace in shell
猜你喜欢

Xcode Revoke certificate

95. (cesium chapter) cesium dynamic monomer-3d building (building)

spark调优(三):持久化减少二次查询

喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配

You Yuxi, coming!

过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?

平衡二叉树(AVL)

Numpy --- basic learning notes

Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?

Unity3D_ Class fishing project, bullet rebound effect is achieved
随机推荐
laravel构造函数和中间件执行顺序问题
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
How can laravel get the public path
Balanced binary tree (AVL)
Wireless sensor networks -- ZigBee and 6LoWPAN
Unity3d click events added to 3D objects in the scene
How does laravel run composer dump autoload without emptying the classmap mapping relationship?
删除 console 语句引发的惨案
laravel中将session由文件保存改为数据库保存
Detailed explanation of several ideas for implementing timed tasks in PHP
SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
MySQL中, 如何查询某一天, 某一月, 某一年的数据
通知Notification使用全解析
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
laravel怎么获取到public路径
分步式监控平台zabbix
如何在shell中实现 backspace
Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
Step by step monitoring platform ZABBIX