<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e" -->

---
title: How Does Recursion Work? Simplified in JavaScript with...
description: Recursion is a concept where a function calls itself and keeps calling itself until it is told to stop. In loops, when the condition for execution forever...
canonical: https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How Does Recursion Work? Simplified in JavaScript with Examples | daily.dev
og:description: Recursion is a concept where a function calls itself and keeps calling itself until it is told to stop. In loops, when the condition for execution forever...
og:url: https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e
og:image: https://api.daily.dev/og/posts/fctlOg26e.png
og:image:alt: How Does Recursion Work? Simplified in JavaScript with Examples
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How Does Recursion Work? Simplified in JavaScript with Examples

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · [@dillionmegida](https://daily.dev/dillionmegida) · 6 min read · 23 upvotes · 0 comments

## Summary

Recursion is a concept where a function calls itself and keeps calling itself until it is told to stop. In loops, when the condition for execution forever remains true, you get an infinite loop which can crash your application. Recursion works similarly to how loops do in JavaScript. To avoid this infinite recursion that maxes out the call stack, we need a condition that stops the recursion.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/recursion-in-javascript-simplified/>

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#recursion](https://daily.dev/tags/recursion)

[View this post on daily.dev](https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How Does Recursion Work? Simplified in JavaScript with Examples","url":"https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e"},"datePublished":"2022-10-07T18:45:56.768Z","dateModified":"2022-10-07T18:45:56.704Z","description":"Recursion is a concept where a function calls itself and keeps calling itself until it is told to stop. In loops, when the condition for execution forever...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/74d2cc9902865d01df02570543e9c48f","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/74d2cc9902865d01df02570543e9c48f","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Dillion Megida","url":"https://daily.dev/dillionmegida","image":"https://lh3.googleusercontent.com/a-/AOh14GhsdJDVct4Ey9D1H1iIIksJ7CSThh8JBubqfjbp4lM=s100","description":"Developer Advocate and Content Creator passionate about simplifying tech via videos and articles and also sharing my life and career experiences.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":450}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-does-recursion-work-simplified-in-javascript-with-examples-fctlog26e","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":23},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,recursion","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"How Does Recursion Work? Simplified in JavaScript with Examples"}]}
```

