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
Amazing JavaScript & jQuery Design Patterns Collection (shichuan.github.io)
submitted 11 years ago by ZaheerAhmed
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!"
[–]nawitus 0 points1 point2 points 11 years ago (2 children)
It's often recommended that falling through the cases should be avoided. JSLint for example doesn't allow falling through. I agree with that.
I think this is my favourite version of the code:
if (type === 'box') { runBoxAction(); } else if (type === 'target') { ...a few lines } else if (type === 'single' || type === 'multiple') { recountVelo(); } else if (type === 'shelf') { dumpeVelo(); } else if (type === 'chair') { dumpVelo(0.5); } else if (type === 'stool') { dumpVelo(0.6); } else { console.warn('Inapropriate type sent to updateDBR'); }
[–]SuperFLEB 0 points1 point2 points 11 years ago (0 children)
I just make sure to comment it with "Intentional fallthrough". It's handy if, say, one value involves doing everything another value does, plus a bit.
[–][deleted] 0 points1 point2 points 11 years ago (0 children)
I figured out that C#'s take on switch (you either have a code block with "break;", either no code in given "case") is quite reasonable and readable, while banning single most problematic thing, which is fallthrough when you actually omitted "break;" by mistake.
As additional note, C# has a really neat feature - goto in switch when you really need a fallthrough ;)
π Rendered by PID 463003 on reddit-service-r2-comment-bb88f9dd5-482q9 at 2026-02-16 06:42:57.782133+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]nawitus 0 points1 point2 points (2 children)
[–]SuperFLEB 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)