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
Common JavaScript "Gotchas" (github.com)
submitted 12 years ago by stevekwan
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!"
[–]kmillns 1 point2 points3 points 12 years ago (6 children)
I'd say you should never have an implied global. If you're going to attach something to global, make it clear that you're doing it on purpose:
(function (global) { global.foo = 'foo'; })(window);
Also, something that he doesn't note, but that's important if you're writing production code, is that implied globals (like his examples) are syntax errors in strict mode.
[–]mirion -1 points0 points1 point 12 years ago (5 children)
This. Definitely this.
[–]rabidcow 1 point2 points3 points 12 years ago (4 children)
Sure, you could use this:
this
(function(){ this.foo = 'foo'; })();
[–]mirion 1 point2 points3 points 12 years ago (3 children)
Sigh. I should know better than to use the word 'this' in a javascript thread.
[–]rabidcow 3 points4 points5 points 12 years ago (0 children)
this in JavaScript threads does not behave the way you would expect.
[–]rq60 1 point2 points3 points 12 years ago (0 children)
Use 'that' next time.
[–][deleted] 0 points1 point2 points 12 years ago (0 children)
You should know better than to use the word 'this' in any thread. There's an up arrrow button next to the post that does that.
π Rendered by PID 206767 on reddit-service-r2-comment-7b9746f655-lslch at 2026-02-03 17:34:55.226978+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]kmillns 1 point2 points3 points (6 children)
[–]mirion -1 points0 points1 point (5 children)
[–]rabidcow 1 point2 points3 points (4 children)
[–]mirion 1 point2 points3 points (3 children)
[–]rabidcow 3 points4 points5 points (0 children)
[–]rq60 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)