please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 5
Statements
Next
 

5.8 continue

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.


Previous Home Next
break Book Index with

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/JAVA/SCRIPT/definitive/ch05_08.htm, 5KB, , updated: 2019/10/14 15:00, local time: 2024/11/26 19:14,
TOP NEW HELP FIND: 
18.226.200.93: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/JAVA/SCRIPT/definitive/ch05_08.htm"> [Chapter 5] 5.8 continue</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .