0

Possible Duplicate:
Best way to break from nested loops in Javascript?

Is using labels to break loops, a good practice in javascript? Mention if it has any pros and cons

Ex:

var i, j;
outer:
    for(i in [0,1,2,3]) { 
    inner:
        for(j in [0,1,2,3]) { 
            if(j == 1) { 
                break outer; 
            }
        } 
        console.log("inner")
    } 
console.log("outer");
Community
  • 1
  • 1
Tamil
  • 5,260
  • 9
  • 40
  • 61

1 Answers1

0

Yes, it is the best way to break out of multiple loops.

alex
  • 479,566
  • 201
  • 878
  • 984