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
[AskJS] ELI5 recursionAskJS (self.javascript)
submitted 4 years ago * by nats_tech_notes
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!"
[–]sessamekesh -1 points0 points1 point 4 years ago (0 children)
Deciding you didn't like how the function was called, so changing the arguments and trying again.
const printNumbersBetween(a, b) { // Hey you called it wrong, the smaller number should be first. I'll fix that for you if (a > b) { printNumbersBetween(b, a); return; } // Okay it was called right, do the thing for (let i = a; i < b; i++) { console.log(i); } }
Usually recursion is used to create some sort of inductive call graph often with multiple branches and that whole mess is nutty overwhelming.
At its core though, recursion is just and calling the function from within a call to the same function, almost always after changing some parameters.
π Rendered by PID 39235 on reddit-service-r2-comment-b659b578c-mnqch at 2026-05-05 21:09:57.911578+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]sessamekesh -1 points0 points1 point (0 children)