当前位置:网站首页>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>
边栏推荐
- laravel怎么获取到public路径
- IP地址和物理地址有什么区别
- You Yuxi, coming!
- Common training data set formats for target tracking
- 2022山东智慧养老展,适老穿戴设备展,养老展,山东老博会
- How to determine whether the checkbox in JS is selected
- php 自带过滤和转义函数
- 修改配置文件后tidb无法启动
- Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!
- Particle effect for ugui
猜你喜欢
AE learning 02: timeline
Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition
删除 console 语句引发的惨案
You Yuxi, coming!
通知Notification使用全解析
Vs tool word highlight with margin
谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
Three. JS introductory learning notes 19: how to import FBX static model
Xcode Revoke certificate
Continuous creation depends on it!
随机推荐
模仿企业微信会议室选择
Performance measure of classification model
MySQL中, 如何查询某一天, 某一月, 某一年的数据
【Vulnhub靶场】THALES:1
three.js打造酷炫下雪效果
iptables只允许指定ip地址访问指定端口
Logback日志框架第三方jar包 免费获取
Iptables only allows the specified IP address to access the specified port
You Yuxi, coming!
47_Opencv中的轮廓查找 cv::findContours()
prometheus api删除某个指定job的所有数据
A JS script can be directly put into the browser to perform operations
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
统计学习方法——感知机
Power of leetcode-231-2
pycharm 终端部启用虚拟环境
Use moviepy Editor clips videos and intercepts video clips in batches
Shader basic UV operations, translation, rotation, scaling
Notification uses full resolution
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement