label

  • Revision slug: JavaScript/Reference/Statements/label
  • Revision title: label
  • Revision id: 65530
  • Created:
  • Creator: Maian
  • Is current revision? No
  • Comment /* Summary */

Revision Content

Summary

Provides a statement with an identifier that you can refer to using a break or continue statement.

For example, you can use a label to identify a loop, and then use the break or continue statements to indicate whether a program should interrupt the loop or continue its execution.

Statement
Implemented in: JavaScript 1.2, NES 3.0
ECMA Version: ECMA-262, Edition 3

Syntax

label :
   statement

Parameters

label 
Any JavaScript identifier that is not a reserved word.
statement 
Statements. break can be used with any labeled statement, and continue can be used with looping labeled statements.

Examples

For an example of a label statement using break, see break. For an example of a label statement using continue, see continue.

See Also

break, continue

Revision Source

<p>
</p>
<h3 name="Summary"> Summary </h3>
<p>Provides a statement with an identifier that you can refer to using a <code>break</code> or <code>continue</code> statement.
</p><p>For example, you can use a label to identify a loop, and then use the <code>break</code> or <code>continue</code> statements to indicate whether a program should interrupt the loop or continue its execution.
</p>
<table class="fullwidth-table">
<tbody><tr>
<td class="header" colspan="2">Statement</td>
</tr>
<tr>
<td>Implemented in:</td>
<td>JavaScript 1.2, NES 3.0</td>
</tr>
<tr>
<td>ECMA Version:</td>
<td>ECMA-262, Edition 3</td>
</tr>
</tbody></table>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval"><i>label</i> :
   <i>statement</i>
</pre>
<h3 name="Parameters"> Parameters </h3>
<dl><dt> <code>label</code> </dt><dd> Any JavaScript identifier that is not a reserved word.
</dd></dl>
<dl><dt> <code>statement</code> </dt><dd> Statements.  <code>break</code> can be used with any labeled statement, and <code>continue</code> can be used with looping labeled statements.
</dd></dl>
<h3 name="Examples"> Examples </h3>
<p>For an example of a label statement using <code>break</code>, see <code><a href="en/Core_JavaScript_1.5_Reference/Statements/break">break</a></code>.  For an example of a label statement using <code>continue</code>, see <code><a href="en/Core_JavaScript_1.5_Reference/Statements/continue">continue</a></code>.
</p>
<h3 name="See_Also"> See Also </h3>
<p><a href="en/Core_JavaScript_1.5_Reference/Statements/break">break</a>,
<a href="en/Core_JavaScript_1.5_Reference/Statements/continue">continue</a>
</p>
Revert to this revision