This is part of a series where I try to explain through each of 33 JS Concepts.
This part corresponds to the JavaScript Call Stack.
Let's get started without further ado.
This is the memory model taken from MDN here. Also note that this is only a visual representation, javascript engines can optimise the representation for performance reasons.
Let us look at purposes of each of these areas.
If you took a Computer Science degree you might remember Heap, well barely. Heap is often taught with respect to Heap Sort which is never used or heard about ever again.
If you thought that was bad, for the purposes of our article, we will not be talking about heap at all. The area denoted by heap in our article will be where JavaScript allocates memory for variables, functions et. all.
Queue is a First in First Out(FIFO) data structure, which means that it acts just a like real world queue.
The first person to stand in the queue is also the first person who will get served. The second person replaces the first in line.
We will revisit what it holds at a later point in time.
Stack is a Last in First Out data structure. Stack is something similar to a small bag structure.