Academy
CoursesInstructors
Academy
HomeCoursesDashboard

© 2026 Academy. All rights reserved.

JavaScript Algorithms & Data Structures

Lesson 3 of 3

Recursion & the Call Stack

See recursion by watching the stack.

Divide and conquer

A recursive function calls itself on a smaller input until it hits a base case.

function factorial(n) {
  if (n <= 1) return 1;   // base case
  return n * factorial(n - 1);
}
factorial(5); // 120

Every call adds a frame to the call stack — forget the base case and you'll overflow it.

Previous lessonArrays vs. Linked ListsYou finishedBack to course

JavaScript Algorithms & Data Structures

Lesson 3 of 3 · 42m total

  1. 1Big-O Notation, Intuitively13:00
  2. 2Arrays vs. Linked Lists15:00
  3. 3Recursion & the Call Stack14:00