JavaScript基本语法使用
- 严格区分大小写:
abc
和Abc
会被解析器认为是两个不同的东西 - 注释:单行注释:
//注释内容
, 多行注释:/*注释内容*/
- 标识符 第一个字符必须是一个
字母
、下划线( _ )
或一个美元符号( $ )
- 标识符采用驼峰命名法: aaBbbCbb
- JavaScript中的标识符不能是
关键字
和保留字符
-
关键字 保留字符
brea | do | instanceof | typeof | case |
---|---|---|---|---|
else | new | var | catch | finally |
return | void | continue | for | switch |
while | default | if | throw | delete |
in | try | function | this | with |
debugger | false | true | null | |
保留字符 | ||||
class | enum | extends | super | const |
import | implements | let | private | public |
interface | package | protected | static |
JavaScript中一共有5种基本数据类型:
- 字符串型(String)
- 数值型(Number)
- 布尔型(Boolean)
- null型(Null)
- undefined型(Undefined)