Thursday, 21 January 2016

JavaScript Break and Continue

The Break Statement
}The break statement "jumps out" of a loop.
The break statement breaks the loop and continues executing the code after the loop (if any):
for (i=0;i<10;i++)
  {
  if (
i==3) break;
  x=x + "The number is " +
i + "<br>";
  }

..............................................................
The continue statement "jumps over" one iteration in the loop.
The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.
for (i=0;i<=10;i++)
 {
 if (
i==3) continue;
  x=x + "The number is " +
i + "<br>";
  }

0 comments:

Post a Comment