Skip to content

Instantly share code, notes, and snippets.

@salomvary
Last active November 25, 2020 11:04
Show Gist options
  • Save salomvary/d268e340bf787689d6b79ce7d8930bd0 to your computer and use it in GitHub Desktop.
Save salomvary/d268e340bf787689d6b79ce7d8930bd0 to your computer and use it in GitHub Desktop.
// Works fine but what does `break` break and `continue` continue?
for (x of y) {
switch (x) {
case '':
if (condition)
continue
else
break
}
// Do more stuff
}
// Labels make it more explicit what break
// and continue apply to (`for` vs `switch`)
loop: for (x of y) {
conditions: switch (x) {
case '':
if (condition)
continue loop;
else
break conditions;
}
// Do more stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment