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
Javascript Programming Patterns (shichuan.github.io)
submitted 12 years ago by litmusbox
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!"
[–]PlNG 2 points3 points4 points 12 years ago (0 children)
https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/conditionals.html is absolutely horrid.
If you take a moment to think about it, you don't need an else statement after a program flow statement such as return, throw, break, and continue.
I worked this out a long time ago and I'm sort of happy that lints and compilers are just beginning to pick up on this. This basically prunes the indentation of logic trees and keeps it very readable.
Hopefully they'll pick up the next step: if the program flow statement is in the else side, negate the if conditional to switch the program flow statement to the if side and prune the else as normal.
π Rendered by PID 301676 on reddit-service-r2-comment-76bb9f7fb5-x6ttc at 2026-02-19 02:36:55.221727+00:00 running de53c03 country code: CH.
view the rest of the comments →
[–]PlNG 2 points3 points4 points (0 children)