

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is continue statement in JavaScript?
The continue statement tells the interpreter to immediately start the next iteration of the loop and skip the remaining code block. The break statement is used to exit a loop early, breaking out of the enclosing curly braces.
When a continue statement is encountered, the program flow moves to the loop check expression immediately and if the condition remains true, then it starts the next iteration, otherwise, the control comes out of the loop.
You can try to run the following to learn how to work with continue statement in JavaScript. This example illustrates the use of a continue statement within a while loop. Notice how to continue statement is used to skip printing when the index held in variable x reaches 5 −
Example
<html> <body> <script> var x = 1; document.write("Entering the loop <br /> "); while (x < 10) { x = x+ 1; if (x== 5) { continue; // skip rest of the loop body } document.write( x + "<br />"); } document.write("Exiting the loop!<br /> "); </script> </body> </html>
- Related Questions & Answers
- The continue statement in JavaScript
- PHP continue Statement
- Continue Statement in C/C++
- Continue statement in Dart Programming
- Java continue statement with Loop
- What is a continue statement in Java and how to use it?
- Continue Statement in C/C++ Programming
- How can I use a label with continue statement in JavaScript?
- What is if statement in JavaScript?
- What is break statement in JavaScript?
- How to use continue statement in Python loop?
- What is the difference between break and continue statements in JavaScript?
- What is Switch...case statement in JavaScript?
- What is while loop statement in JavaScript?
- What is for loop statement in JavaScript?
Advertisements