Break and Continue

break and continue are control statements used inside loops.

Break:

Exits the loop entirely when a condition is met.

for (let i = 0; i < 10; i++) {
  if (i === 5) break;
  console.log(i);
}

Continue:

Skips the current iteration and proceeds to the next one.

for (let i = 0; i < 10; i++) {
  if (i % 2 === 0) continue;
  console.log(i);
}

These are useful for controlling loop flow dynamically.

← PrevNext →