1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- </body>
- <script>
- //注释
- //变量 弱类型语言 不强制要求类型。
- var a = 10
- var b = "100"
- //输出语句
- //弹出内容 alert()
- //alert("hello world")
- //在控制台输出
- //console.log("hello world") //= sout *** 推荐使用
- //页面
- //document.write("hello world")
- //变量
- //格式 var 关键字。
- //规则
- /*
- - 组成字符可以是任何字母、数字、下划线(_)或美元符号($)
- - 数字不能开头
- - 建议使用驼峰命名
- */
- var a = 123;
- var a = 456; //覆盖
- console.log(a)
- // {} 作用域
- {
- var b = 1000;
- }
- console.log(b)
- // 声明变量 let
- {
- let c = 2000
- console.log(c)
- }
- // c is not defined
- //console.log(c)
- //常量
- const PI = 3.14
- //PI = 5.13
- console.log(PI)
- </script>
|