Learn JavaScript

Lesson 5 of 9 · Functions: Declarations, Arrows, Defaults and Rest

Module 5 · Functions: Declarations, Arrows, Defaults and Rest

Under the Hood: The Call Stack, Frames and What a Call Costs

ProReading

Bob wrote a recursive sum, and it worked for 1,000. Then he tried 100,000, and Node stopped with a RangeError. Maria asks the question she always asks: "But why? This laptop has gigabytes of memory, and he only added numbers." This lesson answers her with measurements, not guesses. A call is not free, and the place where calls wait is much smaller than the memory you have.

Checking what this lesson needs for you…

What is inside Under the Hood: The Call Stack, Frames and What a Call Costs

  1. What a frame holds
  2. The limit, measured
  3. Reading a stack trace
  4. The arguments object, and Node's module wrapper
  5. Spread puts every item on the stack
  6. Proper tail calls: in the specification, not in V8
  7. What a call costs: the inlining lab
  8. A function is an object