20_真假.html 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. var a = true;
  11. // 变量未赋值,默认值为undefined
  12. // undefined 如果参与判断那么它代表的是 false
  13. // var b;
  14. // 如果数值型参与判断 那么0为假false 其他所有值均为真 ture
  15. // var c = 6;
  16. // 字符串参与判断 那么空字符串为假false 其他所有值均为真 ture
  17. // var d = "hello";
  18. // null 参与判断 那么它代表的是 false
  19. // var e = null;
  20. // if(e){
  21. // console.log("真")
  22. // }else{
  23. // console.log("假")
  24. // }
  25. // \n 换行 字符串中\开头的内容 表示转义字符
  26. console.log("hello\nworld");
  27. 'hello " world'
  28. // \" \' 转换成字符串进行输出 转义字符
  29. console.log("hello \" world")
  30. </script>
  31. </body>
  32. </html>