Skip to content

Latest commit

 

History

History

recursion

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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-