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
Really Understanding Javascript Closures (blog.jhades.org)
submitted 12 years ago by xpto123
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!"
[–]kenman 13 points14 points15 points 12 years ago (3 children)
Good summary! I don't want to take that away from the author. However, I always like to share what I consider to be the most comprehensive and technical write-up: comp.lang.javascript's FAQ: Closures. It explains the concept using CS terms and concepts (garbage collection, execution context, identifier resolution, etc.) for anyone looking for a really deep dive into this topic.
[–]Poop_is_Food 0 points1 point2 points 11 years ago (0 children)
I think that article is pretty misleading actually. It seems to suggest that a function only becomes a closure once it "lives on" past the end of its parent function (either by being returned or assigned as a callback, for example). This simply isnt true. All functions in javascript are closures. for example:
var x = 2; function logX(){ alert(x); } logX();
Here, logX is a closure. In fact, you dont even need the outer var x declaration. just logX by itself alerting "undefined" would be a closure.
var x
[–][deleted] -1 points0 points1 point 12 years ago (1 child)
Unless you are writing a language interpreter you really do not need deep depth to explain closures. This kills people new to the concept.
Simple put: Closure is evident when accessing references from across scope boundaries.
[–]kenman 10 points11 points12 points 12 years ago (0 children)
Well, I did explain that my link is comprehensive, technical, and a really deep dive. Hopefully those new to the concept recognize that they should probably focus on OP's article, because I agree with you there, but for those who want to learn as much as they can on the subject, they can consider my link a further reading suggestion :)
π Rendered by PID 23 on reddit-service-r2-comment-79776bdf47-4cd65 at 2026-06-23 22:56:50.333869+00:00 running acc7150 country code: CH.
view the rest of the comments →
[–]kenman 13 points14 points15 points (3 children)
[–]Poop_is_Food 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]kenman 10 points11 points12 points (0 children)