break

noun

say it: “BRAYK” /breɪk/

A keyword that stops a loop, or a switch, right away and jumps to the code after it.

What does break do in JavaScript?

break — Stops a loop immediately.

for (const number of numbers) {
    if (number % 2 === 0) {
        continue;
    }

    firstOdd = number;
    break;
}

In a sentence

  • “As soon as the search found the red bike, break stopped the loop.”

Level: Apprentice · More JavaScript terms at this level

Updated

In other subjects