The Wayback Machine - https://web.archive.org/web/20160401071901/https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/break

Creation of new accounts on MDN is unavailable while we devise a solution to an ongoing denial-of-service attack. We're sorry about the inconvenience! If you see something that needs to be fixed, please file a bug: https://bugzilla.mozilla.org/form.doc

現在のループ、switch、またはラベル文を終了し、プログラムの制御を、終了した文の次の文へと移します。

構文

break label;

引数

label
その文のラベルに関連付けられた識別子

説明

break 文は、プログラムがラベル付き文から抜け出すことを可能にする、任意のラベルを含みます。break 文は、このラベル付き文の中にネストされている必要があります。ラベル付き文はどんな種類の文でもかまいません。ループ文である必要さえありません。

以下の関数は、i3 の時に while 文を終了する break 文を持つので、3 * x の値を返します。

function testBreak(x) {
   var i = 0;
   while (i < 6) {
      if (i == 3) break;
      i++;
   }
   return i * x;
}

関連情報

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

タグ: 
 このページの貢献者: teoli, ethertank, Mgjbot, Nanto vi
 最終更新者: teoli,
HTTPS · web.archive.org
← Home