Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 615 Bytes

README.md

File metadata and controls

23 lines (16 loc) · 615 Bytes

Recursion

  • A process (a function) that calls itself.

The call stack

  • It's a stack data structure.
  • Any time a function is invoked it is placed (pushed) on the top of the call stack.
  • When JavaScript sees the return keyword or when the function ends, the compiler will remove (pop)

How recursive functions work

  • Invoke the same function with a different input until you reach your base case!

Base Case

  • The condition when the recursion ends.

Two essential parts of a recursive function!

  • Base case
  • Different Input

Examples-