Break specific nested loops

suggest change

Label a loop and break that label to leave it, including from a nested loop. break without a label leaves only the innermost loop. The unused innerLoop label below shows that a label does nothing until a break or continue names it.

outerloop:
for (let i = 0;i<3;i++){
    innerLoop:
    for (let j = 0;j <3; j++){
        console.log(i);
        console.log(j);
        if (j == 1){
            break outerloop;
        }
    }
}
0
0
0
1

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents