-
Notifications
You must be signed in to change notification settings - Fork 4k
we can use label and break with simple JavaScript blocks and functions #2498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
|
@joaquinelio Wow, I never ever saw Maybe it's worth a better explanation? |
|
Imho, that looks really weird. If This works: foo: {
console.log('face');
break foo;
console.log('this will not be executed');
}
console.log('swap');...But this doesn't (no label): {
console.log('face');
break;
console.log('this will not be executed');
}
console.log('swap'); |
You are right that's my mistake but it does not effect the changed line. functions and blocks must be labeled when they contain break keyword. I just couldn't write good explanation as MDN. |
|
Thanks for the note, I changed some phrases to reflect that. |
|
...Without going much in-detail of that really weird feature =) |
yes really weird :) it feels like |
|
I guess more a side effect than a "feature" |
|
it's not weird, it is beautiful. we can forget the "goto but no goto" thing - and its warnings. ... |
|
not weird but cool pretty clean |
Changed line make me think "we can only use label and break/continue with loops". But this is not totally true. We can use label and break with simple JavaScript blocks and function declarations. So, I tried to make it more clear.
MDN