I wonder how to break a for-loop and switch-case statement at once in JavaScript?
Normally I use something like:
foo:
for(;;)
for (;;)
break foo;
Is there a way to do the same trick with a case at the beginning?
switch(1) {
foo:
case 1:
for (;;)
break foo;
}
Any ideas?
Just use the label for the
switchstatement itself instead of one of the cases. The break will take you out of theswitch, which I think is what you’re trying to do.