_05_js_逻辑运算符.html 654 B

12345678910111213141516171819202122232425262728
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. </head>
  7. <body>
  8. </body>
  9. <script>
  10. // && 优先级高预||
  11. // console.log(true && NaN && 0 && "") // Nan
  12. // console.log(1 && "123" && 0 && false) //0
  13. // console.log("hello" && "123" && 1 && true) // true
  14. // // 0|| Nan || ""
  15. // console.log(0|| NaN || "hello" && "") // ""
  16. // //true && "" ""
  17. // // undefined ||NaN || ""
  18. // console.log(undefined ||NaN || true && "") //""
  19. // console.log(true && 123 || NaN && false) //123
  20. var age = 20
  21. if(age > 18){
  22. console.log("成年")
  23. }else{
  24. console.log("未成年")
  25. }
  26. </script>
  27. </html>