user1243746
user1243746

Reputation:

List of reserved words in JavaScript

Is there any more complete list than Mozilla's about reserved words?

It lacks words like parseFloat, toString, prototype, etc.

Upvotes: 5

Views: 1933

Answers (1)

Matt
Matt

Reputation: 75317

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 as FutureReservedWord tokens within strict mode code. (section 7.6.1.2).

Upvotes: 11

Related Questions