关键字和保留字
ECMA-262描述了一组有特定用途的关键字,这些关键字可用于表示控制语句的开始或结束,或者用于执行特定操作等,不能用作标识符。
下面是ECMAScript的关键字:
breakdoinstanceoftypeof
caseelsenewvar
catchfinallyreturn
voidcontinueforswitch
whiledebuggerfunctionthis
withdefaultifthrow
deleteintry
ECMA-262还描述了一组不能用作表示符的保留字。下面是ECMA-262第3版的全部保留字:
abstractenumintshort
booleanexportinterfacestatic
byteextendslongsuper
charfinalnativesynchronized
classfloatpackagethrows
constgotoprivatetransient
debuggerimplementsprotectedvolatile
doubleimportpublic
第5版在非严格模式下运行时的保留字缩减为下列这些
classenumextendssuper
constexportimport
在严格模式下,第5版还对以下保留字施加了限制
implementspackagepublic
interfaceprivatestatic
letprotectedyield