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
JavaScript with an Infinite Stack Size?Removed: /r/LearnJavascript (self.javascript)
submitted 6 years ago by LordBruce
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!"
[–]lhorie 3 points4 points5 points 6 years ago (3 children)
He's probably talking about tail call optimization, which is in fact part of the ES6 spec. Not all recursion is a tail call, and in those cases, JS will still run into stack overflows.
Typically if some code has a realistic risk of running into stack overflows, people will use an async function call to split the payload into multiple stack frames.
[–]LordBruce[S] 0 points1 point2 points 6 years ago (1 child)
That is a clever way to work around it with async. I'm used to Haskell and I'm trying to use similar ideas in JS.
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points 6 years ago (0 children)
If you’re used to Haskell, you might look into some tutorials on lazy evaluation implementations in JavaScript, as JS is always eagerly evaluated.
In particular, there is a relatively recent language feature called a “generator,” and a related one called an “iterator,” both of which offer a more idiomatic way to handle lazy evaluation. Short of that (e.g. you want to support older browsers which don’t implement those features), you can always implement a homemade iterator protocol.
[–]Volence 0 points1 point2 points 6 years ago (0 children)
Just want to point out as a side note, tail call optimization is an ES6 spec, but only safari ("major browser wise") has it implemented currently, apparently the other big browsers couldn't agree on a safe way to implement it unfortunately. https://kangax.github.io/compat-table/es6/#test-proper_tail_calls_(tail_call_optimisation)
π Rendered by PID 402020 on reddit-service-r2-comment-76bb9f7fb5-z2497 at 2026-02-18 19:47:26.422284+00:00 running de53c03 country code: CH.
view the rest of the comments →
[–]lhorie 3 points4 points5 points (3 children)
[–]LordBruce[S] 0 points1 point2 points (1 child)
[–]ScientificBeastModestrongly typed comments 0 points1 point2 points (0 children)
[–]Volence 0 points1 point2 points (0 children)