How Recursion works with the Call Stack in JavaScript

preview_player
Показать описание
Recursion is a concept where a function calls itself and keeps calling itself until something stops it. This also means that the function is continuously added to the call stack until there is a "Maximum call stack size exceeded error" error.

In this video, I explain what this error means by showing you how Recursion works with the call stack.

_____

_____

🌟 About Me:
Dillion Megida, creator of DEEECODE, is a Software Engineer, Developer Advocate and a Content Creator passionate about simplifying topics around Tech via articles and videos.

_____

⚡️ Connect with me:

_____
#deeecode
Рекомендации по теме
Комментарии
Автор

Thank you very much for this. I'm struggling a little with the concept of recurssion, and I really needed to see a visualisation of of how this looks in the call stack. Very helpful 🙂

curtisx
Автор

Great video. Was looking to get a refresher on this but really surprised to see the lack of content on this particular topic using call stack.

shahriarsakil
Автор

One thing I am confused about is why the console.log 7 comes last if it is the first function to pop off the call stack. Wouldn't that mean it should be logged first?

GusselSprout
Автор

Gr8 to see how the recursive function works. Thanks for sharing this. One request if you share a video with the below use case that would more of clarify my all recursion scenarios. Please refer to the below use case
function foo(i) {
if (i < 0) {
return;
}
console.log(`begin: ${i}`);
foo(i - 1);
console.log(`end: ${i}`);
}
foo(3);

bikukist
Автор

best explanation so far..thank youn for this

aslemisaac