Skip to main content

Break and Continue

Break and Continue is a core JavaScript concept covering break and Continue: The break statement "jumps out" of a loop. This topic is essential for academic learning, board exam preparation, and developing optimized real-world code.

The Break Statement

The break statement "jumps out" of a loop.

for (let i = 0; i < 10; i++) {
if (i === 3) { break; }
text += "The number is " + i + "<br>";
}

The Continue Statement

The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.

for (let i = 0; i < 10; i++) {
if (i === 3) { continue; }
text += "The number is " + i + "<br>";
}

Labels

To jump out of a nested loop, you can use labels.

list: {
text += cars[0] + "<br>";
text += cars[1] + "<br>";
break list; // Jumps out of the list block
text += cars[2] + "<br>";
}
Labels

Labels are rarely used in modern JavaScript development, but it's good to know they exist.

📍 Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
📍 Address
2/66 Faram Street, Rustompura
Surat395002, Gujarat, India
📞 Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition — Areas We Serve in Surat

AdajanAlthanAmroliAthwaAthwalinesBhagalBhatarBhestanCanal RoadChowkCitylightDumasGaurav PathGhod Dod RoadHaziraJahangirpuraKamrejKapodraKatargamLimbayatMagdallaMajura GateMota VarachhaNanpuraNew CitylightOlpadPalPandesaraParle PointPiplodPunaRanderRing RoadRustampuraSachinSalabatpuraSarthanaSosyo CircleUdhnaVarachhaVed RoadVesuVIP Road
📞 Call Sir💬 WhatsApp Sir