Keyword (Definition)

The keywords that ECMAScript defines should be avoided when you create your own identifier or variable names.

A keyword is a word that has special significance in the JavaScript language. It follows the rules that ECMA lays down for describing identifiers. All of the JavaScript keywords are reserved and define the language syntax. You must not use any of them as identifier names for variables, properties, methods and functions that you define.

ECMAScript reserves a set of keywords for future use. These are intended to make provision for future language features and to give developers warning that they should avoid using these keywords in order that their scripts should continue to operate when the language is revised.

Other special names are defined by JavaScript to identify properties of the Global object and constructor functions of the built-in data types. You should avoid these too, unless you are intentionally overriding their functionality with your own.

Here is a list of keywords that ECMA edition 2 mandates a compliant implementation should support:

In addition, these are constants that should also be avoided:

The third edition of the ECMA standard adds these keywords which in the earlier edition were reserved for future use:

The remaining reserved keywords as of edition 3 are:

However, you should note that Netscape anticipates a future standard and supports these already:

The JavaScript 2.0 project defines these which should also be avoided and which will likely be added to a later edition of the ECMAScript standard:

Many implementations of JavaScript will introduce additional keywords. Some will provide functional behavior for the reserved keywords. To remain ECMAScript compliant, the reserved words specified in edition 3 must be supported sufficiently to prevent parsing errors, but need not provide any meaningful functionality.

You can code defensively to avoid any future problems. Using an underscore character or digit in your identifier names should improve the chances of your script continuing to operate properly in later versions of the language. Using upper case may help, but is less of a guarantee of safety. In particular, you should be very careful to avoid the names of properties and methods belonging to the Global object.

See also:Lexical element, Reserved word, Token


ECMA 262 edition 2 - section - 7.4.2

ECMA 262 edition 3 - section - 7.5.2