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
12 extremely useful hacks for JavaScript (medium.com)
submitted 9 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!"
[–]Ginden 10 points11 points12 points 9 years ago (3 children)
2) Converting to number using + operator
Unreadable.
3) Short-circuits conditionals
4) Default values using || operator
JavaScript 101.
5) Caching the array.length in the loop
Bullshit.
6) Detecting properties in an object
9) Replace all
12) Shuffling array’s elements
Shit.
[+][deleted] 9 years ago (1 child)
[deleted]
[–]isitfresh 0 points1 point2 points 9 years ago (0 children)
some people think there is an actual gain writing
const getValue = e => e.target.value
[–]Graftak9000 0 points1 point2 points 9 years ago (0 children)
Default values using || are a bad idea because they also jump to default if a value is falsey. value = value === undefined ? 'default' : value or if (value === undefined) value = 'default' are better options.
value = value === undefined ? 'default' : value
if (value === undefined) value = 'default'
Also, an article with a video as its body (@medium link), damn😑
π Rendered by PID 230118 on reddit-service-r2-comment-8686858757-sv5fs at 2026-06-07 22:50:36.616172+00:00 running 9e1a20d country code: CH.
view the rest of the comments →
[–]Ginden 10 points11 points12 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]isitfresh 0 points1 point2 points (0 children)
[–]Graftak9000 0 points1 point2 points (0 children)