Call Stack and Memory Heap

In JavaScript engine, there are Call Stack and Memory Heap.

  • Call Stack: Where are in code in order
  • Memory Heap: A place to store and write

We need the memory heap as a place to store and write information.

With Call Stack, we need a place to keep track of we are in the code in order.

Every time, we run the code we use call stack. We can think of call stack as a region in memory that operates in first in last out mode.

function subThree(num) {
  return num - 3;
function calculate(num) {
  const sumTotal = num;
  return subThree(sumTotal);

Call Stack [it run first in last out]


Leave a Reply

Your email address will not be published.