当前位置:网站首页>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>
边栏推荐
- 47_ Contour lookup in opencv cv:: findcontours()
- [summary of knowledge] summary of notes on using SVN in PHP
- [flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
- 招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
- 企业级日志分析系统ELK
- 【C 语言】 题集 of Ⅹ
- 喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
- The unity vector rotates at a point
- Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
- PHP has its own filtering and escape functions
猜你喜欢

【C 语言】 题集 of Ⅹ

统计学习方法——感知机

分步式監控平臺zabbix

Three. JS introductory learning notes 19: how to import FBX static model

融云斩获 2022 中国信创数字化办公门户卓越产品奖!

【Android -- 数据存储】使用 SQLite 存储数据

Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?

星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”

预测——灰色预测

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"?
随机推荐
Step by step monitoring platform ZABBIX
统计学习方法——感知机
The inevitable trend of the intelligent development of ankerui power grid is that microcomputer protection devices are used in power systems
Xcode Revoke certificate
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
laravel post提交数据时显示异常
How does geojson data merge the boundaries of regions?
删除 console 语句引发的惨案
Continuous creation depends on it!
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
Sysom case analysis: where is the missing memory| Dragon lizard Technology
spark调优(三):持久化减少二次查询
Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
Description of vs common shortcut keys
预测——灰色预测
PHP实现微信小程序人脸识别刷脸登录功能
A JS script can be directly put into the browser to perform operations
Power of leetcode-231-2
How does laravel run composer dump autoload without emptying the classmap mapping relationship?
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?