The continue statement “jumps over” one iteration in the loop. It breaks iteration in the loop and continues executing the next iteration in the loop.
continue labelname;
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
for(var a = 1; a <= 10; a++){
if(a == 3){
document.write("Hey : " + a + "<br>");
continue;
}
document.write("Number : " + a + "<br>");
}
</script>
</head>
<body>
</body>
</html>
The break statement is used to jump out of a loop. It can be used to “jump out” of a switch() statement. It breaks the loop and continues executing the code after the loop.
break labelname;
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
for(var a = 1; a <= 10; a++){
if(a == 3){
document.write("Hey : " + a + "<br>");
break;
}
document.write("Number : " + a + "<br>");
}
</script>
</head>
<body>
</body>
</html>