Break outer loop from inner nested loop: — Rare to use but better to know
Apr 23, 2023
I was reading a book then come to know cool feature, thought to share
most of time till now I was using outer scope variable as flag but now its easy use labels for loops then break it the way you want
outer: for(let i = 0; i < 10 ; ++i){
console.log('outer',i);
inner: for(let j = 0; j < 10; ++j){
console.log('Inner',j);
if(i == 5){
break outer;
}
}
}