mozilla

Revision 33125 of let

  • Revision slug: JavaScript/Reference/Statements/let
  • Revision title: let
  • Revision id: 33125
  • Created:
  • Creator: tehsis
  • Is current revision? No
  • Comment 6 words removed

Revision Content

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

Let allows to declare variables limiting its scope to the block, statement or expression on which is used.

Examples

 

    
   

See also

{{ languages( { "ja": "ja/JavaScript/Reference/Statements/let"} ) }}

Revision Source

{{ Non-standard_header() }}{{ stub() }} {{ js_minversion_header("1.7") }}
<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>Let allows to declare variables limiting its scope to the block, statement or expression on which is used.</p><h2>Examples</h2>
<p> </p>
<pre class="brush: js">    
   </pre>
<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>
<p>{{ languages( { "ja": "ja/JavaScript/Reference/Statements/let"} ) }}</p>
Revert to this revision