<!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分支语句
if(3<5){
alert('真')
}else{
alert('假')
}
//条件 ? 代码1 : 代码2
3 < 5 ? alert('真') : alert('假')
//一般用来取值
let num = 3 < 5 ? 3 : 5
console.log(sum)
</script>
</body>
</html>
09_三元运算符
最新推荐文章于 2024-07-18 15:09:01 发布