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

label 文

label 文

label を使うと、そのプログラムのどこからでも参照できる、識別子を持った文を作ることができます。例えば、ラベルを使用してあるループに名前を付けると、break 文や continue 文を使用してプログラムがループを脱出するべきかそのまま実行を継続するべきかを示すことができます。

label 文は次のように使用します。

label :
   statement

label の値は予約語でなければどんな JavaScript の識別子でも使用できます。ラベルを用いて名前を付ける statement はどんな文でも結構です。


この例では markLoop というラベルを用いて while ループに名前を付けています。

markLoop:
while (theMark == true)
   doSomething();
}

ドキュメントのタグと貢献者

 このページの貢献者: ethertank, happysadman, Electrolysis
 最終更新者: ethertank,