Break out of a while statement in JavaScript
Description
The following code shows how to break out of a while statement.
Example
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var x = 0;<!-- w ww.ja v a 2s . c o m-->
while (x < 10)
{
x++;
document.write(x);
break;
document.write("Never seen!");
}
</script>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Break Continue
Continue a while loop in JavaScript
Continue statement in a if statement in Jav...
Continue to a label in JavaScript
Put Break statement in a if statement in Ja...
Use Mod operator to check even number in Ja...
Use break statement to jump to outer loop i...
Use continue statement to jump to outer mos...
Break out of a while statement in JavaScrip...
Break to a label in JavaScriptContinue a while loop in JavaScript
Continue statement in a if statement in Jav...
Continue to a label in JavaScript
Put Break statement in a if statement in Ja...
Use Mod operator to check even number in Ja...
Use break statement to jump to outer loop i...
Use continue statement to jump to outer mos...