aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/mots_réservés/index.html
blob: 01dfd777bea88a0343d1b69aa9dbbbe1a47dcf3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
title: Mots réservés
slug: Web/JavaScript/Reference/Mots_réservés
translation_of: Web/JavaScript/Reference/Lexical_grammar#Keywords
---
<h3 id="Introduction">Introduction</h3>

<p>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 <a href="/fr/ECMAScript" title="fr/ECMAScript">ECMAScript</a> spécifie une utilité spéciale pour eux.</p>

<h3 id="Mots_actuellement_réservés">Mots actuellement réservés</h3>

<p>Voici la liste des mots réservés actuellement utilisés en JavaScript :</p>

<ul>
 <li><a href="/en/JavaScript/Reference/Statements/break" title="en/JavaScript/Reference/Statements/break">break</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/switch" title="en/JavaScript/Reference/Statements/switch">case</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/try...catch" title="en/JavaScript/Reference/Statements/try...catch">catch</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/continue" title="en/JavaScript/Reference/Statements/continue">continue</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/debugger" title="en/JavaScript/Reference/Statements/debugger">debugger</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/switch" title="en/JavaScript/Reference/Statements/switch">default</a></li>
 <li><a href="/en/JavaScript/Reference/Operators/Special/delete" title="en/JavaScript/Reference/Operators/Special/delete">delete</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/do...while" title="en/JavaScript/Reference/Statements/do...while">do</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/if...else" title="en/JavaScript/Reference/Statements/if...else">else</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/try...catch" title="en/JavaScript/Reference/Statements/try...catch">finally</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/for" title="en/JavaScript/Reference/Statements/for">for</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/function" title="en/JavaScript/Reference/Statements/function">function</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/if...else" title="en/JavaScript/Reference/Statements/if...else">if</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/for...in" title="en/JavaScript/Reference/Statements/for...in">in</a></li>
 <li><a href="/en/JavaScript/Reference/Operators/Special/instanceof" title="en/JavaScript/Reference/Operators/Special/instanceof">instanceof</a></li>
 <li><a href="/en/JavaScript/Reference/Operators/Special/new" title="en/JavaScript/Reference/Operators/Special/new">new</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/return" title="en/JavaScript/Reference/Statements/return">return</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/switch" title="en/JavaScript/Reference/Statements/switch">switch</a></li>
 <li><a href="/en/JavaScript/Reference/Operators/Special/this" title="en/JavaScript/Reference/Operators/Special/this">this</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/throw" title="en/JavaScript/Reference/Statements/throw">throw</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/try...catch" title="en/JavaScript/Reference/Statements/try...catch">try</a></li>
 <li><a href="/en/JavaScript/Reference/Operators/Special/typeof" title="en/JavaScript/Reference/Operators/Special/typeof">typeof</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/var" title="en/JavaScript/Reference/Statements/var">var</a></li>
 <li><a href="/en/JavaScript/Reference/Operators/Special/void" title="en/JavaScript/Reference/Operators/Special/void">void</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/while" title="en/JavaScript/Reference/Statements/while">while</a></li>
 <li><a href="/en/JavaScript/Reference/Statements/with" title="en/JavaScript/Reference/Statements/with">with</a></li>
</ul>

<h3 id="Mots_réservés_dans_le_futur">Mots réservés dans le futur</h3>

<p>Les mots suivants sont de futurs mots-clés réservés par la spécification ECMAScript. Bien qu'ils ne soient actuellement pas utilisés, ils ne peuvent pas servir d'identifiants d'objets car ils seront bientôt fonctionnels. (Notez que pour le moment, Mozilla réserve ces mots-clés seulement dans le code en mode strict. La plupart des autres navigateurs réservent ces mots-clés pour tout le code, qu'il soit strict ou non. Leur utilisation est souvent incompatbile entre les différents navigateurs. Mozilla réservera ces mots-clés à un code normal à l'avenir, pour correspondre aux spécifications des autres navigateurs).</p>

<p>{{ gecko_minversion_header("2.1") }}</p>

<div class="note"><strong>Note: </strong>En commençant avec Javascript 1.9 (Firefox 5), ces derniers seront réservés même lorsque vous n'êtes pas en mode strict.<br>
<strong>Note: La version de JavaScript ci-dessus n'est pas officielle.</strong></div>

<ul>
 <li>class</li>
 <li>enum</li>
 <li><a href="/en/JavaScript/Reference/Statements/export" title="en/JavaScript/Reference/Statements/export">export</a></li>
 <li>extends</li>
 <li><a href="/en/JavaScript/Reference/Statements/import" title="en/JavaScript/Reference/Statements/import">import</a></li>
 <li>super</li>
</ul>

<p>Les mots suivants sont de futurs mots-clés réservés par la spécification ECMAScript lorsqu'ils se situent dans de code en mode strict, excepté lorsque <code>let</code> et <code>yield</code> ont leurs fonctions traditionnelles dans le code compilé comme JavaScript 1.7 ou plus:</p>

<ul>
 <li>implements</li>
 <li>interface</li>
 <li><a href="/JavaScript/Reference/Statements/let" title="JavaScript/Reference/Statements/let">let</a></li>
 <li>package</li>
 <li>private</li>
 <li>protected</li>
 <li>public</li>
 <li>static</li>
 <li><a href="/en/JavaScript/Reference/Statements/yield" title="en/JavaScript/Reference/Statements/yield">yield</a></li>
</ul>

<p>Note that while <a href="/en/JavaScript/Reference/Statements/const" title="en/JavaScript/Reference/Statements/const">const</a> 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, <a href="/en/JavaScript/Reference/Statements/export" title="en/JavaScript/Reference/Statements/export">export</a> and <a href="/en/JavaScript/Reference/Statements/import" title="en/JavaScript/Reference/Statements/import">import</a> were once implemented in Mozilla but have returned to reserved status in recent releases.</p>

<p>Additionally, the literals <code>null</code>, <code>true</code>, and <code>false</code> are reserved in ECMAScript for their normal uses.</p>

<h2 id="Reserved_Word_Usage">Reserved Word Usage</h2>

<p>Reserved Words actually only apply to Identifiers (vs. <span class="comment-copy">IdentifierNames) </span>. <span class="comment-copy">As described in <a href="http://es5.github.com/#A.1" rel="nofollow">es5.github.com/#A.1</a>, these are all IdentifierNames which do not exclude ReservedWords.</span></p>

<p><span class="comment-copy"><code>a.import</code></span><br>
 <span class="comment-copy"><code>a["import"]</code></span><br>
 <span class="comment-copy"><code>a = { import: "test" }</code>.</span></p>

<p><span class="comment-copy">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.</span></p>

<p><span class="comment-copy"><code>function import() {}</code></span></p>

<p> </p>

<p>{{ languages( { "es": "es/Referencia_de_JavaScript_1.5/Palabras_Reservadas", "fr": "fr/R\u00e9f\u00e9rence_de_JavaScript_1.5_Core/Mots_r\u00e9serv\u00e9s", "ja": "ja/Core_JavaScript_1.5_Reference/Reserved_Words", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/S\u0142owa_zarezerwowane" } ) }}</p>