Stack Overflow in Javascript| Call Stack| Interview Question

preview_player
Показать описание
Stack overflow is a situation or condition that occurs due to bad recursion in javascript.
A stack overflow occurs when there is a recursive function (a function that calls itself) without an exit point. The browser (hosting environment) has a maximum stack call that it can accomodate before throwing a stack error.

To understand stack overflow, its very important to understand about Call Stack.

A call stack is a mechanism for an interpreter (like the JavaScript interpreter in a web browser) to keep track of its place in a script that calls multiple functions — what function is currently being run and what functions are called from within that function, etc.

1) When a script calls a function, the interpreter adds it to the call stack and then starts carrying out the function.
2) Any functions that are called by that function are added to the call stack further up, and run where their calls are reached.
3) When the current function is finished, the interpreter takes it off the stack and resumes execution where it left off in the last code listing.
4 ) If the stack takes up more space than it had assigned to it, it results in a "stack overflow" error.

Support my channel by liking and sharing my videos so that I can reach to wider audience. Please share it in your network 🙏

Connect with me on social platform:

For more such interesting videos, please subscribe to my channel and stay connected.

#StackOverflow #NishaSingla #CallStack
Рекомендации по теме
Комментарии
Автор

Wow.. you are an amazing teacher! You made this concept very easy while teaching me how to leverage the chrome dev tools 🤩 also.. it’s starting to click(no pun intended hehe) I’m starting to see how that FILO data stack structure comes into play and JS Event loop as well 🙌🏽

I’m going to share with my network and also come up with my own examples for practice! U are the GOAT

yardleyfrausto
Автор

Kindly make Angular state management and ChangeDetectorRef tutorial

faizal