ECMA-262 描述了一组保留的关键字,这些关键字有特殊用途,比如表示控制语句的开始和结束,或者执行特定的操作。按照规定,保留的关键字不能用作标识符或属性名。
ECMA-262 规定的所有关键字如下:
await debugger finally
break default for
case do function
catch else if
class export import
const extends in
continue false instanceof
new null return
super switch this
throw true try
typeof var void
while with yield
规范中也描述了一组未来的保留字,同样不能用作标识符或属性名。虽然保留字在语言中没有特定用途,但它们是保留给将来做关键字用的。
始终保留:
enum
严格模式下保留:
arguments eval implements interface
package private protected public static