Javascript Reference
Categories: LABEL

javascript LABEL Description

@March 15, 2008, 1:22 a.m.
labelFirefox/Netscape/NN 4 IE 4 ECMA 3  

  

You can assign a label identifier to any block of executing statements, including control structures. The purpose of the label is to allow break and continue statements within deeply nested control structures to exit to a nested level that may be at levels beyond the scope of the normal break and continue statements.

 
Example
 
outerLoop:
for (var i = 0; i <= maxValue1; i++) {
    for (var j = 0; j <= maxValue2; j++) {
        if (i == magic1 && j == magic2) {
            break outerLoop;
        }
    }
}

Powered by Linode.