Recursion

Function pow(x, n) {
  if (n == 1) {
    return x;
  } else {
    return x * pow(x, n - 1);
  }
}

alert( pow(2, 3) ); // 8
  • Is a programming pattern that is useful in situations when a task can be naturally split into several tasks of the same kind, but simpler.
  • Is a programming term that means a "self-calling" function.
  • When a function calls itself, that's called a recursion step.

Related concepts

Recursion

Recursion — Structure map

Clickable & Draggable!

Recursion — Related pages: