JavaScript Control Flow Loops

Break

The break statement terminates the current loop; works for both for and while loops. break jumps to the statement that follows the loop.

for (let i = 0; i < 10; i++) {
if (i === 2) {
break;
}
console.log(i)
}
console.log('first statement after loop')
// 0
// 1
// first statement after loop