<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script type="text/javascript">
var iNum01 = 2;
var sNnm02 = '2';
/* === 先比较两边的类型,然后再进行比较 */
if (iNum01 === sNnm02){
alert('相等');
}
else{
alert('不相等');
}
if (3!=4){
alert(true);
}
else{
alert(false);
}
if (!4>3){
alert('大于');
}
else{
alert('不大于');
}
// 多个条件运算,都是true,最终结果才是true
if (4>3 && 5>2){
alert('都大于');
}
else{
alert('不是都大于');
}
// 多个条件中只要有一个是true,最终结果就是true
if (4>3 || 5>6){
alert('部分大于');
}
else{
alert('不是都大于');
}
</script>
</head>
<body>
</body>
</html>
web----if条件语句练习代码
最新推荐文章于 2020-07-18 17:44:07 发布