continue statement with example in JavaScript

JavaScript continue statement: Here, we are going to learn about the continue statement in JavaScript with example.
Submitted by IncludeHelp, on March 11, 2019

JavaScript continue statement

continue is a keyword in JavaScript, it is used with the looping statements to continue the loop's iteration.

When a continue statement executes, it breakouts the current loop's iteration and continues to the next loop's iteration.

Syntax:

    continue;

Example of continue statement in JavaScript

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	var loop = 1;
	//continues when value of loop is 7
	for(loop=1; loop<=10; loop++){
		if(loop==7)
			continue;
		document.write(loop + " ");
	}
	document.write("<br>");
	document.write("Outside of the loop<br>");
</script>
</body>
</html>

Output

1 2 3 4 5 6 8 9 10 
Outside of the loop

JavaScript Tutorial »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.