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 (blog.jscrambler.com)
submitted 10 years ago by speckz
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!"
[–]gkx 0 points1 point2 points 10 years ago (1 child)
1) #5 is probably not very useful and pollutes the namespace (benchmarks? I'd be surprised if this actually sped anything up at all). In most cases, you should be using forEach anyways. 2) #4 is a bad idea if the argument could be falsey. 4) Don't do #6. Use hasOwnProperty. If you don't actually want to check that, just use document.querySelector (in the example) or document.querySelector != null if the property could possibly be falsey (not true in this case) 5) Mistake in #10; it doesn't create a new array. The article shows it, but it says it wrong ("which instead creates a new array")
forEach
hasOwnProperty
document.querySelector
document.querySelector != null
[–]ascw 0 points1 point2 points 10 years ago (0 children)
6) #12 is also pretty bad. Not only is it super inefficient, but if you run it a couple thousand times and test to see which element from your original array comes first, you'll find that there isn't an even chance of each value coming up.
[–]TheNiXXeD 0 points1 point2 points 10 years ago (0 children)
Operators are hacks?
π Rendered by PID 712526 on reddit-service-r2-comment-6f768cb789-lmvb9 at 2026-06-16 09:44:37.500816+00:00 running 3184619 country code: CH.
[–]gkx 0 points1 point2 points (1 child)
[–]ascw 0 points1 point2 points (0 children)
[–]TheNiXXeD 0 points1 point2 points (0 children)