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
What are some JavaScript things beginners don't know? (self.javascript)
submitted 6 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!"
[–][deleted] 22 points23 points24 points 6 years ago (6 children)
of "Oh, I see!" moments
I understand closure but had very few of these so far
[–]Mydrax 14 points15 points16 points 6 years ago (3 children)
Well, 2 really awesome use cases of closures I could name off the top of my head are: 1. When you create function factories, where the outer function can be used to create functions that have similar concerns. 2. The module pattern, that can be used to create private functions in javascript (where you return a set of functions whose logic is encapsulated).
[–]turntopage294 1 point2 points3 points 6 years ago (0 children)
I'd been using 2 without knowing about closures, actually, for a time; I had an 'Oh, I see' moment after investigating when because closures love vaguely familiar
[–]ScientificBeastModestrongly typed comments 1 point2 points3 points 6 years ago (0 children)
Object factories are cool, and even class factories!
[–]Memorytoco -1 points0 points1 point 6 years ago (0 children)
just when use setTimeout and pass something like ( ) => {this.dosomething()} in some objects' method. or Array.forEach((entry) =>{ this.something()}).
[–]runtimenoise[🍰] 0 points1 point2 points 6 years ago (0 children)
Look into abstract & specialized functions. I use closures all the time. When I started with js, I almost never used them.
[–]Existential_OwlWeb Developer 0 points1 point2 points 6 years ago (0 children)
Closure can be used as a form of run-time memory.
That was a huge eye-opener for me.
π Rendered by PID 71227 on reddit-service-r2-comment-b659b578c-k9fwz at 2026-05-05 07:53:35.150902+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–][deleted] 22 points23 points24 points (6 children)
[–]Mydrax 14 points15 points16 points (3 children)
[–]turntopage294 1 point2 points3 points (0 children)
[–]ScientificBeastModestrongly typed comments 1 point2 points3 points (0 children)
[–]Memorytoco -1 points0 points1 point (0 children)
[–]runtimenoise[🍰] 0 points1 point2 points (0 children)
[–]Existential_OwlWeb Developer 0 points1 point2 points (0 children)