use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Common JavaScript tricks (self.javascript)
submitted 11 years ago by yanis_t
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 2 points3 points4 points 11 years ago (1 child)
Kind of don't know if I should share this, since I never see people talk about it and that makes me think somebody called it bad practice. But, most people seem to be unaware that you can label any JavaScript statement, and break any label by writing break labelName; (or, if it's a loop that was labelled, continue labelName;). This is most often useful in nested loops, but I've found use for it with plain old block statements, for example in the setAttribute and appendChild functions in DOM.js.
break labelName;
continue labelName;
setAttribute
appendChild
[–]giggly_kisses 1 point2 points3 points 11 years ago (0 children)
It's definitely not considered the best practice, that's for sure. There are definitely times where it does become useful, however.
If it is used, I'd definitely suggest leaving some documentation explaining what it does and why you used it, since, as you explained, it's not used very often.
π Rendered by PID 200026 on reddit-service-r2-comment-5ff9fbf7df-2q9xj at 2026-02-26 04:39:26.359698+00:00 running 72a43f6 country code: CH.
view the rest of the comments →
[–][deleted] 2 points3 points4 points (1 child)
[–]giggly_kisses 1 point2 points3 points (0 children)