MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 33117 of let

  • Revision slug: JavaScript/Reference/Statements/let
  • Revision title: let
  • Revision id: 33117
  • Created:
  • Creator: user01
  • Is current revision? No
  • Comment 10 words added, 6 words removed

Revision Content

js_minversion_header("1.7");

Summary

Declares a local variable, optionally initializing it to a value.

Syntax

let definition:

let var1 [= value1] [, var2 [= value2]] [, ..., varN [= valueN]];

let expression:

let (var1 [= value1] [, var2 [= value2]] [, ..., varN [= valueN]]) expression;

let statement:

let (var1 [= value1] [, var2 [= value2]] [, ..., varN [= valueN]]) statement;

Parameters

Parameter Description
var1, var2, …, varN Variable name. It can be any legal identifier.
value1, value2, …, valueN Initial value of the variable. It can be any legal expression.
expression Any legal expression.
statement Any legal statement.

Description

See New in JavaScript 1.7.

Examples

See New in JavaScript 1.7.

See also

Revision Source

<pre class="script" style="font-size: 16px;">js_minversion_header("1.7");
</pre>
<h2>Summary</h2>
<p>Declares a local variable, optionally initializing it to a value.</p>
<h2>Syntax</h2>
<p><code>let</code> definition:</p>
<pre class="brush: js">let var1 [= value1] [, var2 [= value2]] [, ..., varN [= valueN]];
</pre>
<p><code>let</code> expression:</p>
<pre class="brush: js">let (var1 [= value1] [, var2 [= value2]] [, ..., varN [= valueN]]) expression;
</pre>
<p><code>let</code> statement:</p>
<pre class="brush: js">let (var1 [= value1] [, var2 [= value2]] [, ..., varN [= valueN]]) statement;
</pre>
<h2>Parameters</h2>
<table class="standard-table" style=""> <thead> <tr> <th scope="col">Parameter</th> <th scope="col">Description</th> </tr> </thead> <tbody> <tr> <td><code>var1</code>, <code>var2</code>, …, <code>varN</code></td> <td>Variable name. It can be any legal identifier.</td> </tr> <tr> <td><code>value1</code>, <code>value2</code>, …, <code>valueN</code></td> <td>Initial value of the variable. It can be any legal expression.</td> </tr> <tr> <td><code>expression</code></td> <td>Any legal <a href="/en/JavaScript/Guide/Expressions_and_Operators#Expressions" title="en/JavaScript/Guide/Expressions and Operators#Expressions">expression</a>.</td> </tr> <tr> <td><code>statement</code></td> <td>Any legal <a href="/en/JavaScript/Reference/Statements" title="en/JavaScript/Reference/Statements">statement</a>.</td> </tr> </tbody>
</table>
<h2>Description</h2>
<p>See <a href="/en/JavaScript/New_in_JavaScript/1.7#Block_scope_with_let_(Merge_into_let_Statement)" title="en/JavaScript/New in JavaScript/1.7#Block scope with let (Merge into let Statement)">New in JavaScript 1.7</a>.</p>
<h2>Examples</h2>
<p>See <a href="/en/JavaScript/New_in_JavaScript/1.7#Block_scope_with_let_(Merge_into_let_Statement)" title="en/JavaScript/New in JavaScript/1.7#Block scope with let (Merge into let Statement)">New in JavaScript 1.7</a>.</p>
<h2>See also</h2>
<ul> <li><a href="/en/JavaScript/Reference/Statements/var" title="en/JavaScript/Reference/Statements/var"><code>var</code></a></li> <li><a href="/en/JavaScript/Reference/Statements/const" title="en/JavaScript/Reference/Statements/const"><code>const</code></a></li> <li><a href="/en/JavaScript/New_in_JavaScript/1.7#Block_scope_with_let_(Merge_into_let_Statement)" title="en/JavaScript/New in JavaScript/1.7#Block scope with let (Merge into let Statement)">New in JavaScript 1.7</a></li>
</ul>
Revert to this revision