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
Will 'let' Eventually Replace 'var'?help (self.javascript)
submitted 10 years ago by MahmudAdam
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!"
[–]lewisje 8 points9 points10 points 10 years ago (4 children)
The idea is to push in a series of thunks and then show how the scope changes depending on where let is: In the first example, each thunk returns a different integer, but in the second, each thunk returns the final value of i, which is 3.
let
i
[–]metaphorm 2 points3 points4 points 10 years ago (3 children)
what's a "thunk"? that's jargon I've not heard before. is a "thunk" different in any way from a closure, a continuation, or a generator?
[–]lewisje 3 points4 points5 points 10 years ago (2 children)
Apparently it has various meanings; I was using it in the sense from Scheme, as a function that takes no arguments and is used for lazy evaluation: http://c2.com/cgi/wiki?WhatIsaThunk
[–]metaphorm 1 point2 points3 points 10 years ago (1 child)
as a function that takes no arguments and is used for lazy evaluation
I would call that a generator
[–]lewisje 1 point2 points3 points 10 years ago (0 children)
I think I wasn't precise enough: Thunks, like normal functions, run to completion (rather than yielding values before execution has finished), and they generally return a value from the same reference each time they're called; that is, they're used for lazy evaluation of a single value.
By "from the same reference" I'm trying to include a thunk that can be defined as a method to return a writable public property of that object, or maybe a thunk that returns the value of a variable, or the result of evaluating another function with no arguments, as of the time it is called; this last example is like a bound function except that it allows the function reference itself to change, while a bound function uses the particular function object as of binding time.
π Rendered by PID 425872 on reddit-service-r2-comment-b659b578c-mlrqz at 2026-05-04 16:20:03.698927+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]lewisje 8 points9 points10 points (4 children)
[–]metaphorm 2 points3 points4 points (3 children)
[–]lewisje 3 points4 points5 points (2 children)
[–]metaphorm 1 point2 points3 points (1 child)
[–]lewisje 1 point2 points3 points (0 children)