Labeled Statement

Microsoft Office JScript

Microsoft® JScript® Labeled Statement  Language Reference 
Version 3 


Description
Provides an identifier for a statement.
Syntax
label :
    statement

Labeled statement syntax has these parts:

Part Description
label A unique identifier used when referring to the labeled statement.
statement The statement associated with label. May be a compound statement.

Remarks
Labels are used by the break and continue statements to specify the statement to which the break and continue apply.

In the following statement the continue statement uses a labeled statement to create an array in which the third column of each row contains and undefined value:

function labelDemo()
{
    var a = new Array();
    var i, j, s = "", s1 = "";
  Outer:
    for (i = 0; i < 5; i++)
    {
      Inner:
        for (j = 0; j < 5; j++)
        {  
          if (j == 2)
            continue Inner;
          else
            a[i,j] = j + 1;
        }
    }

    for (i = 0;i < 5; i++)
    {
      s = ""
      for (j = 0; j < 5; j++)
      {
        s += a[i,j];
      }
      s1 += s + "\n";
    }
    return(s1)
}