我们在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);
alert(1 === true);
alert(typeof null);
alert(typeof NaN);
alert(typeof undefined);
alert(null == NaN);
alert(null == undefined);
alert(undefined == NaN);
alert(null === NaN);
alert(null === undefined);
alert(undefined === NaN);
</script>
</body>
</html>