stackoverflow in javascript
Javascript is based on single thread and callback queue.
The engine consists of memory heap and call stack.
- Memory heap : memory allocation
- Callstack : stack the commands code by code
Runtime = The environment
Most developers use web API, which is not given by JS engine.
callstack
It is data structure that logs where I am in a program, which means what commands completed.
Example (normal callstack)
In the call stack, result is
Each steps of call stack are called “Stack Frame”.
Example (stack trace)
Stack trace is a statement of call stack when exception happened.
Example (stack overflow)
It shows when eternal loop is executed.
Call stack has maximum. When stack is over the maximum, it is called stack overflow.
And then, it blows the call stack, which is called “blowing the stack”.
Single thread is simple, but it has a lot of limitations.
To solve the limitation (slow), we use event loop and asynchronous.