Javascript does not have goto
- thankfully. But it has continue
and break
that more or less perform the same function.
If for any reason you want to jump out of a loop, here’s how you can do that -
|
|
But, what if you want to jump to a particular statement? That’s where break
can help.
|
|
Similar to break
, you can use continue
to continue loop.
|
|
And, when used with labels..
|
|
Final words
Just use conditional statements to execute logic as normal. There is no place for labels in this day and age.
- Do not use
continue
- ever - Use break to break out of the inner loop, but never with labels