问题
Is there any more complete list than Mozilla's about reserved words?
It lacks words like parseFloat, toString, prototype, etc.
回答1:
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).
来源:https://stackoverflow.com/questions/10397951/list-of-reserved-words-in-javascript