JavaScript中保留字的列表 [英] List of reserved words in JavaScript
问题描述
是否有比 Mozilla的更完整的列表? >
它缺少诸如 parseFloat , toString , prototype 之类的词.
parseFloat
,toString
和prototype
是非保留字.仅仅因为它们有时具有特殊含义,并不意味着您不能使用其名称声明变量;
var prototype = "foo"; // no error.
ES5标准也包含保留字列表,但应匹配MDN给出的列表:
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
class, enum, extends, super, const, export, import
您可能还对 ES5的严格变体添加了额外的单词感兴趣. 保留的列表;
在严格模式代码中,标识符
"implements", "interface", "let", "package", "private", "protected", "public", "static", and "yield"
被分类为FutureReservedWord
令牌. (第7.6.1.2节).
Is there any more complete list than Mozilla's about reserved words?
It lacks words like parseFloat, toString, prototype, etc.
parseFloat
, toString
and prototype
are not reserved words. Just because they sometimes have a special meaning, doesn't mean you can't declare variables with their names;
var prototype = "foo"; // no error.
The ES5 standard contains a list of reserved words as well, but it should match the list given by MDN:
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
class, enum, extends, super, const, export, import
It might also be of interest to you that the strict varient of ES5 adds additional words to the reserved list;
The identifiers
"implements", "interface", "let", "package", "private", "protected", "public", "static", and "yield"
are classified asFutureReservedWord
tokens within strict mode code. (section 7.6.1.2).
这篇关于JavaScript中保留字的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!