<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
/* if案例 */
if (false) {
console.log('执行了1。');
} else if (false) {
console.log('执行了2。');
} else {
console.log('执行了3。');
}
/* 三元表达式案例 */
console.log(1 == 0 ? '1=0正确' : '1=0错误。');
/* switch案例 */
var a = 1;
switch (a) {
case 0:
console.log('a=0。');
break;
case 1:
console.log('a=1。');
break;
default:
console.log('a即不是0也不是1。');
break;
}
</script>
</head>
<body>
</body>
</html>
JS判断方法及应用
猜你喜欢
转载自blog.csdn.net/qq_39706570/article/details/106756046
今日推荐
周排行