aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/statements/continue/index.html
blob: b6b00242def44709807a159b77660e5260c7f23a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
title: continue
slug: Web/JavaScript/Reference/Statements/continue
tags:
  - JavaScript
  - Statement
translation_of: Web/JavaScript/Reference/Statements/continue
---
<div>{{jsSidebar("Statements")}}</div>

<p>Die <strong>continue </strong>Anweisung beendet die Ausführung von Anweisungen im aktuellen Durchlauf der aktuellen oder benannten Schleife und setzt die Schleife mit der nächsten Iteration fort.</p>

<div>{{EmbedInteractiveExample("pages/js/statement-continue.html")}}</div>



<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">continue [<em>label</em>];</pre>

<dl>
 <dt><code>label</code></dt>
 <dd>Bezeichner mit dem Namen der verbundenen Anweisung.</dd>
</dl>

<h2 id="Beschreibung">Beschreibung</h2>

<p>Im Gegensatz zur {{jsxref("Statements/break", "break")}} Anweisung, beendet <code>continue</code> die Ausführung der Schleife nicht komplett sondern:</p>

<ul>
 <li>In einer {{jsxref("Statements/while", "while")}} Schleife wird zur Bedingung gesprungen.</li>
</ul>

<ul>
 <li>In einer {{jsxref("Statements/for", "for")}} Schleife wird zur Schlussanweisung gesprungen.</li>
</ul>

<p>Die <code>continue</code> Anweisung kann optional den Namen beinhalten und erlaubt dem Programm zum nächsten Durchlauf einer benannten Schleife zu springen anstatt der aktuellen. In diesem Fall muss die <code>continue</code> Anweisung innerhalb der benannten Anweisung liegen.</p>

<h2 id="Beispiele">Beispiele</h2>

<h3 id="Verwendung_von_continue_mit_while">Verwendung von <code>continue</code> mit <code>while</code></h3>

<p>Das folgende Beispiel zeigt eine {{jsxref("Statements/while", "while")}} Schleife mit einer <code>continue</code> Anweisung, die ausgeführt wird, wenn <code>i</code> den Wert 3 hat. Daher nimmt <code>n</code> die Werte 1, 3, 7, und 12 an.</p>

<pre class="brush: js">var i = 0;
var n = 0;

while (i &lt; 5) {
  i++;

  if (i === 3) {
    continue;
  }

  n += i;
}
</pre>

<h3 id="Verwendung_von_continue_mit_einem_Bezeichner">Verwendung von <code>continue</code> mit einem Bezeichner</h3>

<p>Im folgenden Beispiel enthält die <code>checkiandj</code> benannte Anweisung eine benannte Anweisung namens <code>checkj</code>. Wenn <code>continue</code> erreicht wird, wird das Programm am Beginn der <code>checkj</code> Anweisung fortgesetzt. Jedes mal wenn <code>continue</code> erreicht wird, beginnt <code>checkj</code> einen neuen Durchlauf, bis die Bedingung <em>false</em> zurückgibt. Wenn <em>false</em> zurückgegeben wird, wird der Rest der <code>checkiandj</code> Anweisung ausgeführt.</p>

<p>Falls <code>continue</code> einen Bezeichner <code>checkiandj</code> hätte, dann würde das Programm am Beginn der <code>checkiandj</code> Anweisung fortgesetzt.</p>

<p>Siehe auch {{jsxref("Statements/label", "label")}}.</p>

<pre class="brush: js">var i = 0;
var j = 8;

checkiandj: while (i &lt; 4) {
  console.log('i: ' + i);
  i += 1;

  checkj: while (j &gt; 4) {
    console.log('j: '+ j);
    j -= 1;

    if ((j % 2) == 0)
      continue checkj;
    console.log(j + ' is odd.');
  }
  console.log('i = ' + i);
  console.log('j = ' + j);
}
</pre>

<p>Ausgabe:</p>

<pre class="brush: js">i: 0

// start checkj
j: 8
7 is odd.
j: 7
j: 6
5 is odd.
j: 5
// end checkj

i = 1
j = 4

i: 1
i = 2
j = 4

i: 2
i = 3
j = 4

i: 3
i = 4
j = 4
</pre>

<h2 id="Spezifikationen">Spezifikationen</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">kommentar</th>
  </tr>
  <tr>
   <td>{{SpecName('ES1')}}</td>
   <td>{{Spec2('ES1')}}</td>
   <td>Initiale Definition. Unbenannte Version.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES3')}}</td>
   <td>{{Spec2('ES3')}}</td>
   <td>Benannte Version hinzugefügt.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-12.7', 'Continue statement')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-continue-statement', 'Continue statement')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-continue-statement', 'Continue statement')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browserkompatibilität">Browserkompatibilität</h2>



<p>{{Compat("javascript.statements.continue")}}</p>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{jsxref("Statements/break", "break")}}</li>
 <li>{{jsxref("Statements/label", "label")}}</li>
</ul>