8_运算3.html 419 B

123456789101112131415161718
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. var a = 4;
  12. // a>5 a = -a
  13. // a<5 a = a
  14. console.log(a>5?-a:a)
  15. //三目运算符 三元运算符 判断条件? true:false
  16. </script>
  17. </body>
  18. </html>