demo03.html 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. //变量 弱类型语言 不强制要求类型。
  12. var a = 10
  13. var b = "100"
  14. //输出语句
  15. //弹出内容 alert()
  16. //alert("hello world")
  17. //在控制台输出
  18. //console.log("hello world") //= sout *** 推荐使用
  19. //页面
  20. //document.write("hello world")
  21. //变量
  22. //格式 var 关键字。
  23. //规则
  24. /*
  25. - 组成字符可以是任何字母、数字、下划线(_)或美元符号($)
  26. - 数字不能开头
  27. - 建议使用驼峰命名
  28. */
  29. var a = 123;
  30. var a = 456; //覆盖
  31. console.log(a)
  32. // {} 作用域
  33. {
  34. var b = 1000;
  35. }
  36. console.log(b)
  37. // 声明变量 let
  38. {
  39. let c = 2000
  40. console.log(c)
  41. }
  42. // c is not defined
  43. //console.log(c)
  44. //常量
  45. const PI = 3.14
  46. //PI = 5.13
  47. console.log(PI)
  48. </script>