# Call Stack, Heap, Queue

# Call Stack

Call stack is data structure indicates that records of function calls.

function foo() {
  throw new Error("Oops");
}
function bar() {
  foo();
}
function baz() {
  bar();
}
baz();

// Uncaught Error: Oops
//    at foo (<anonymous>:1:22)
//    at bar (<anonymous>:1:16)
//    at baz (<anonymous>:1:16)
//    at <anonymous>:1:1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

As we run the above file, when baz was executed, baz() would push on the call stack, then bar was executed in the same way, bar() also push on the call stack and at top of baz(). As console error shows.

# Heap

All the memory allocation to variables and objects happens in Heap

# Queue

A JavaScript runtime contains a message queue, which is a list of messages to be processed and the associated callback functions to execute.

# Event Loop

d