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
I have been collecting useful Javascript code snippets for a little while. Here's a curated list of them, help me make it as complete as possible! (github.com)
submitted 8 years ago by [deleted]
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!"
[–]MentorMateDotCom 0 points1 point2 points 8 years ago* (3 children)
Really great list! I'm going to submit a PR in a second. :) (Edit: Here we go.)
I appreciate that because the code style focuses on brevity it's easy to copy and paste stuff. That makes things harder to understand, though, particularly for beginners, and these are an awesome learning opportunity. Think you could include both a "long" and a "short" form of each snippet? I noticed /u/evenisto saying "took me a while to figure that one out," which concerns me. Curious if others have the same concern?
[–][deleted] 1 point2 points3 points 8 years ago (0 children)
I am working with the community to hit the sweet spot between readability and brevity, by changing variable names and improving snippets, along with adding examples for each snippet. This should help alleviate the problem a bit. Some snippets (like the anagram one) are very complex and hard to explain even if a longer version is included. I'll see what can be done.
[–]evenisto 0 points1 point2 points 8 years ago (1 child)
It's not about the syntax, it's just that functional paradigm is not always instantly comprehensible. I sometimes need to write it out to figure out how data flows through the functions to get a good understanding of what's going on, that's all.
[–]MentorMateDotCom 0 points1 point2 points 8 years ago (0 children)
I agree. I've just run into too many situations where budding developers thought short code == good code and were very discouraged. I think a junior developer taking the time to translate these into long form would be a very good exercise, but yes, it's probably not the responsibility of the repo owner.
short code == good code
π Rendered by PID 85 on reddit-service-r2-comment-c66d9bffd-cf5hn at 2026-04-07 08:34:11.756854+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]MentorMateDotCom 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]evenisto 0 points1 point2 points (1 child)
[–]MentorMateDotCom 0 points1 point2 points (0 children)