Introduction
Cet annexe présente les mots réservés. Les mots réservés ne doivent pas être utilisés en tant que noms de variables, de fonctions, de méthodes ou d'identifiants d'objets parce-que ECMAScript spécifie une utilité spéciale pour eux.
Mots actuellement réservés
Voici la liste des mots réservés actuellement utilisés en JavaScript :
- break
- case
- catch
- continue
- debugger
- default
- delete
- do
- else
- finally
- for
- function
- if
- in
- instanceof
- new
- return
- switch
- this
- throw
- try
- typeof
- var
- void
- while
- with
Mots réservés dans le futur
The following are reserved as future keywords by the ECMAScript specification. They have no special functionality at present, but they might at some future time, so they cannot be used as identifiers. (Note that for the moment Mozilla reserves these keywords only in strict mode code. Most other browsers reserve these keywords in all code, whether strict or not, so their use is very much non-portable. Mozilla will likely reserve these keywords in normal code in a future release, to conform to the specification and to be consistent with other browsers).
The following are reserved as future keywords by the ECMAScript specification when they are found in strict mode code, except that let
and yield
have their traditional Mozilla-specific functionality in code compiled as JavaScript 1.7 or greater:
Note that while const is reserved as a future keyword by the ECMAScript specification, Mozilla and most other browsers implement it as a non-standard extension that may be standardized in a future version of ECMAScript. Further, export and import were once implemented in Mozilla but have returned to reserved status in recent releases.
Additionally, the literals null
, true
, and false
are reserved in ECMAScript for their normal uses.
Reserved Word Usage
Reserved Words actually only apply to Identifiers (vs. IdentifierNames) . As described in es5.github.com/#A.1, these are all IdentifierNames which do not exclude ReservedWords.
a.import
a["import"]
a = { import: "test" }
.
On the other hand the following is illegal because it's an Identifier, which is an IdentifierName without the Reserved Words. Identifiers are used for FunctionDeclaration and FunctionExpression.
function import() {}