JavaScript的关键字和保留字
一、概念
- 关键字:用于表示控制语句的开始或结束,或者用于执行特定操作等
- 按照规则,关键字是语言保留的,不能用作标识符
二、关键字
- 以下是ECMAScript的全部关键字(带*号上标的是第五版新增的关键字)
break | do | instanceof | typeof |
---|---|---|---|
case | else | new | var |
catch | finally | return | void |
continue | for | switch | while |
debugger* | function | this | with |
default | if | throw | delete |
in | try | let* | yield* |
- ECMA-262还描述了另外一组不能用作标识符的保留字。尽管保留字在这门语言中还没有任何规定,但它们可能在将来被用作关键字
abstract | enum | int | short |
---|---|---|---|
boolean | export | interface | static |
byte | extends | long | super |
char | final | native | synchronized |
class | float | package | throws |
const | goto | private | transient |
debugger | implenments | protected | volatile |
double | import | public |
源于整理《JavaScript高级程序设计》