break
is used to exit a loop prematurely.continue
is used to skip the current iteration and proceed to the next iteration of the loop.
Example:
for (let i = 0; i < 5; i++) {
if (i === 3) break;
console.log(i); // 0, 1, 2
}
Tags: basic, JavaScript, control flow
URL: https://www.tiktok.com/@jsmentoring/photo/7456440125774433569