
JavaScript have Break and Continue keyword. This break keyword use when we won’t our condition are full then stop the execution. But continue is use when our condition is full only full fill condition are stop but other code is Continue to execution. Break is full stop when condition is match but continue is only stop which condition are match otherwise code are executing as well. Now given bellow the break and continue code and explain the code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
for(var i=0;i<=10;i++){
//continue
if (i==2||i==5) {
continue;
}
//break keyword
console.log("Show the value of i: "+i);
if (i==6) {
break;
}
}
</script>
</body>
</html>
In this code for loop print the value 0 to 10. Continue statement responsible to 2 and 5 value are not print but break statement responsible to stop the code when I value is 6 also this code is stop now so 7 to 10 are not print.