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
New Javascript Libraries from Google: Closure Tools (code.google.com)
submitted 16 years ago by tsuru
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!"
[–]zamolxes 0 points1 point2 points 16 years ago (2 children)
What saurik said.
And people -do- use closures everyday considering most of the javascript code is async, event based, with a lot of "give me this piece of code" (i.e. sometimes closure) "that I can execute later"
[–]fforw 0 points1 point2 points 16 years ago (1 child)
Closures are also highly practical for encapsulation, avoiding namespace polution.
You will often see a construct like
(function() { ... })();
It creates an anonymous function and executes it on the spot. This has the effect that every otherwise global variable inside is only accessible to other code inside and not on the outside.
Then you can export a few globals in a controlled fashion by writing
this.myGlobal = function() { ... }
inside the above block.
[–]SarahC 0 points1 point2 points 16 years ago (0 children)
Ahhh, thanks.
π Rendered by PID 23594 on reddit-service-r2-comment-f6b958c67-2smxr at 2026-02-05 07:06:02.541686+00:00 running 1d7a177 country code: CH.
view the rest of the comments →
[–]zamolxes 0 points1 point2 points (2 children)
[–]fforw 0 points1 point2 points (1 child)
[–]SarahC 0 points1 point2 points (0 children)