![js--3目运算符 js--3目运算符](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>hello world</title>
</head>
<body>
<script type="text/javascript">
window.onload= function myf(){
var a=5>2;
var b=2;
var c=3;
var Max=a?b:c;
alert(Max)//1.如果a的值为true,计算b的值,运算结果为b的值; 2.否则,计算c的值,运算结果为c的值。
}
</script>
</body>
</html>
结果会弹出2