关系(比较)运算:
等于 = = 简单的做字面值的比较
全等于 = = = 除了做字面值的比较之外,还会比较两个变量的数据类型
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
var a = "12";
var b = 12;
alert(a == b); //true
</script>
</head>
<body>
</body>
</html>
运行结果:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
var a = "12";
var b = 12;
alert(a === b); //flase(还需要比较变量的数据类型)
</script>
</head>
<body>
</body>
</html>
运行结果: