JavaScript has Gotos?
When there is a loop sitting inside another loop, a break or continue statement will affect only the inner loop. Sometimes you want to jump out of the outer loop. To be able to refer to a specific loop, loop statements can be labelled. A label is a name (any valid variable name will do), followed by a colon (:).
outer: for (var sideA = 1; sideA < 10; sideA++) {
inner: for (var sideB = 1; sideB < 10; sideB++) {
var hypotenuse = Math.sqrt(sideA * sideA + sideB * sideB);
if (hypotenuse % 1 == 0) {
print("A right triangle with straight sides of length ",
sideA, " and ", sideB, " has a hypotenuse of ",
hypotenuse, ".");
break outer;
}
}
}