Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Mots réservés

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 :

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).

Note: Starting in JavaScript 1.9 (Firefox 5), these will be reserved even when not in strict mode. NOTE: JavaScript version number here is not official.

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:

  • implements
  • interface
  • let
  • package
  • private
  • protected
  • public
  • static
  • yield

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() {}

 

Étiquettes et contributeurs liés au document

 Contributeurs à cette page : teoli, SphinxKnight, matteodelabre
 Dernière mise à jour par : teoli,