Javascript learning data type, the need for better understanding null and undefined
same point: equal to null and undefined values of
differences: undefined and not equal to null type
We can define two variables test1 and test2
var test1 = null;
var test2 = undefined;
Js file and then write a judge
directly on the code:
var test1 = null;
var test2 = undefined;
document.getElementById("demo").innerHTML =
"test1的类型: " + typeof test1 + "<br/>" +
"test2的类型: " + typeof test2 + "<br/>" +
"test1 和 test2 的值是否相等: " + ( test1 == test2 )+ "<br/>" +
"test1 和 test2 的类型是否相等: " + ( test1 === test2 );
Supporting html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Javascript学习第二天</title>
</head>
<body>
<p id="demo"></p>
<script src="../Javascript/0114_01.js"></script>
</body>
</html>
operation result:
supplement:
In JavaScript
typeof operator returns the type of a variable
two equal sign ==
determination values are equal
three equal sign ===
is determined whether or not simultaneously equal type and value