goto for JS
class OutJump(Exception):
pass
outjump = OutJump()
destination = "first"
while True:
try:
if destination == "first":
print("first")
destination = "third"
raise outjump
elif destination == "second":
print("second")
elif destination == "third":
print("third")
except OutJump as e:
pass
else:
break
var destination = "first"
topLabel: while (true) {
var jump = false;
switch (destination) {
case "first": // caseがラベル相当
console.log("first");
//ここから
destination = "third";
jump = true;
break;
//ここまでが goto third;
case "second":
console.log("second");
case "third":
console.log("third");
}
if (jump) {
continue topLabel;
}
break;
}
first:
printf("first\n")
goto third;
second:
printf("second\n");
thrid:
printf("third\n");