<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
if(5 > 2){
console.log('执行语句');
}
//除了0 所有的数字都为真
if(0){
console.log('执行语句');
}
//除了''(空字符串)所有的字符串都为真
if('阿巴阿巴'){
console.log('执行语句');
}
//小案例
let credit = +prompt('请输入高考成绩:')
if(credit > 700){
alert('恭喜考入');
}
</script>
</body>
</html>
06_if单分支语句
最新推荐文章于 2024-07-12 09:36:48 发布