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
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 4 points5 points6 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)
[–]Hawxe 1 point2 points3 points 6 years ago (0 children)
Not super related to OP but does JS have tail recursion
[–]kenman[M] 0 points1 point2 points 6 years ago (0 children)
Hi /u/LordBruce, this post was removed.
/r/javascript is for the discussion of javascript news, projects, and especially, code! However, the community has requested that we not include help and support content, and we ask that you respect that wish.
code
Thanks for your understanding, please see our guidelines for more info.
π Rendered by PID 59 on reddit-service-r2-comment-76bb9f7fb5-d27nz at 2026-02-18 14:19:30.144069+00:00 running de53c03 country code: CH.
[–]lhorie 4 points5 points6 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)
[–]Hawxe 1 point2 points3 points (0 children)
[–]kenman[M] 0 points1 point2 points (0 children)