<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> 关系运算符 </title>
<script type="text/javascript">
var num1 = 101;
var num2 = 102;
if (num1 == num2)
{
window.alert ("num1 等于 num2");
}
if(num1 > num2)
{
window.alert ("num1大于num2");
}
if (num1 < num2)
{
window.alert ("num1小于num2");
}
if (num1 >= num2)
{
window.alert ("num1 大于等于num2");
}
if (num1 <= num2)
{
window.alert ("num1 小于等于 num2");
}
if (num1 != num2)
{
window.alert ("num1 不等于 num2");
}
var str1 = "123";
var str2 = 123;
if (str1 == str2)
{
window.alert ("str1 == str2");
}
if (str1 === str2)
{
window.alert ("str1 === str2");
}
</script>
</head>
<body>
</body>
</html>
小结:
1.=== 在js中,对比 值 和 类型同时比较,只有当值和类型都相等时,才成立;
2.==等于 ===全等
alert:提示框