About the Continue Statement

The continue statement is similar to break in that it terminates execution of a part of a loop. However, unlike break, continue only skips execution of the remaining steps in the current iteration instead of terminating the entire loop.

See About the Break Statement.

For example, the following code adds all positive numbers in list:

var total=0,n;
for(n=0; list[n]!=null; n++) {
  if(list[n]<0)
    continue;
  total+=list[n];
}

This example is exactly like the first example using break, except continue is substituted for break. In this example, each time you encounter a negative number, the remaining steps in the current loop are skipped. Since there is only one remaining step in the statement block, total+=list[n];, the loop is simply summing positive list elements.