Javascript关键字(Reserved Words)是指在Javascript语言中有特定含义,成为Javascript语法中一部分的那些字。Javascript关键字是不能作为变量名和函数名使用的。使用Javascript关键字作为变量名或函数名,会使Javascript在载入过程中出现编译错误。
Javascript的中的关键字一般分为三类,关键字、保留关键字、避免使用的关键字。
Javascript关键字及保留字
abstract
break boolean byte
case catch continue char class const
default delete do debugger double
else enum export extends
finally for function final float
goto
if in instanceof implements import int interface
long
new native
package private protected public
return
switch short static super synchronized
this throw try typeof throws transient
var void volatile
while with
另外除了这些关键字之外,还应当避免使用Name、Type、Date等单词作为变量名称。如果误用了这些关键字,可能会导致JS脚本不能正常执行。