/ FRONT-END

stackoverflow in javascript

Javascript is based on single thread and callback queue.

runtime2

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)

processimg

In the call stack, result is

processimg

Each steps of call stack are called “Stack Frame”.


Example (stack trace)

processimg

Stack trace is a statement of call stack when exception happened.

processimg


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”.

processimg

processimg

processimg

Single thread is simple, but it has a lot of limitations.
To solve the limitation (slow), we use event loop and asynchronous.