diff options
author | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:07:59 +0100 |
---|---|---|
committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 12:07:59 +0100 |
commit | 6ef1fa4618e08426b874529619a66adbd3d1fcf0 (patch) | |
tree | 890e3e27131be010d82ef957fa68db495006cb0e /files/ja/web/javascript/guide/loop_statements/for_statement | |
parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
download | translated-content-6ef1fa4618e08426b874529619a66adbd3d1fcf0.tar.gz translated-content-6ef1fa4618e08426b874529619a66adbd3d1fcf0.tar.bz2 translated-content-6ef1fa4618e08426b874529619a66adbd3d1fcf0.zip |
unslug ja: move
Diffstat (limited to 'files/ja/web/javascript/guide/loop_statements/for_statement')
-rw-r--r-- | files/ja/web/javascript/guide/loop_statements/for_statement/index.html | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/files/ja/web/javascript/guide/loop_statements/for_statement/index.html b/files/ja/web/javascript/guide/loop_statements/for_statement/index.html deleted file mode 100644 index b2dccec25b..0000000000 --- a/files/ja/web/javascript/guide/loop_statements/for_statement/index.html +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: for 文 -slug: Web/JavaScript/Guide/Loop_Statements/for_Statement ---- -<h3 id="for_.E6.96.87" name="for_.E6.96.87">for 文</h3> -<p><code>for</code> ループは指定した条件が false に評価されるまで繰り返します。JavaScript の for ループは Java や C の for ループに似ています。<code>for</code> 文は次のように使用します。</p> -<pre class="eval">for ([initialExpression]; [condition]; [incrementExpression]) - statement -</pre> -<p><code>for</code> ループを実行すると以下のことが起こります。</p> -<ol> - <li>初期化式 <code>initialExpression</code> があれば実行されます。この式は通常、1 つかそれ以上のループカウンタを初期化しますが、構文的にはある程度複雑な式も指定できます。また、この式は変数を宣言することもできます。</li> - <li><code>condition</code> 式が評価されます。<code>condition</code> の値が true であればループ文が実行されます。<code>condition</code> が false の場合は <code>for</code> ループは終了します。<code>condition</code> 式が完全に省略されている場合、条件は true であると仮定されます。</li> - <li><code>statement</code> が実行されます。複数の式を実行するにはブロック文 (<code>{ ... }</code>) を使用して文をグループ化してください。</li> - <li>更新式 <code>incrementExpression</code> があれば実行されます。そしてコントロールがステップ 2 に戻ります。</li> -</ol> -<p><strong>例</strong><br> - 次の関数には、スクローリングリスト(複数選択できる Select オブジェクト)で選択されたオプションの数を数える <code>for</code> 文が含まれています。<code>for</code> 文では変数 <code>i</code> が宣言され、それが 0 に初期化されています。<code>i</code> が <code>Select</code> オブジェクトのオプションの個数より小さいかをチェックし、続く <code>if</code> 文を実行し、ループが 1 回りしたら <code>i</code> を 1 だけ増加させます。</p> -<pre><script type="text/javascript">//<![CDATA[ - -function howMany(selectObject) { - var numberSelected = 0; - for (var i = 0; i < selectObject.options.length; i++) { - if (selectObject.options[i].selected) - numberSelected++; - } - return numberSelected; -} - -//]]></script> -<form name="selectForm"> - <p> - <strong>Choose some music types, then click the button below:</strong> - <br/> - <select name="musicTypes" multiple="multiple"> - <option selected="selected">R&B</option> - <option>Jazz</option> - <option>Blues</option> - <option>New Age</option> - <option>Classical</option> - <option>Opera</option> - </select> - </p> - <p> - <input type="button" value="How many are selected?" - onclick="alert ('Number of options selected: ' + howMany(document.selectForm.musicTypes))"/> - </p> -</form> -</pre> -<p>{{ PreviousNext("JavaScript/Guide/Loop_Statements", "JavaScript/Guide/Loop_Statements/do...while_Statement") }}</p> |