The continue statement is related to the break statement and has a syntax that is just as simple:
continue;
Like the break statement, continue can be used only within the body of a while, for, or for/in loop. Using it anywhere else will cause a syntax error.
When the continue statement is executed, the current iteration of the enclosing loop is terminated, and the next iteration begins. In a while loop, the specified expression is tested again, and if true, the loop body is executed. In a for loop, the increment expression is evaluated, then the test expression is tested again to determine if another iteration should be done. In a for/in loop, the loop starts over with the next property name being assigned to the specified variable.
The following example shows the continue statement being used to abort the current iteration of a loop when an error occurs:
for(i =index.html 0; i < data.length; i++) { if (data[i] == null) continue; // can't proceed with undefined data total +=index.html data[i]; }
Note the difference in behavior of the continue statement for the while and for loops--a while loop returns directly to its condition, but a for loop first evaluates it increment expression, and then returns to its condition. Above, in the discussion of the for loop, we explained the behavior this loop in terms of an "equivalent" while loop. But because the continue statement behaves differently for these two loops it is never possible to perfectly simulate a for loop with a while loop.
file: /Techref/language/java/script/definitive/ch05_08.htm, 5KB, , updated: 2019/10/14 15:00, local time: 2024/11/15 12:30,
52.14.90.36:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.ecomorder.com/Techref/language/java/script/definitive/ch05_08.htm"> [Chapter 5] 5.8 continue</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to massmind.ecomorder.com! |
.