recursion

A technique where a function solves a problem by calling itself on a smaller version of the same problem.

In more detail

Every recursive function needs a base case that stops the calls, or it will recurse forever. Each call that has not yet returned occupies a frame on the call stack, so deep recursion uses memory proportional to its depth. Trees, divide and conquer, and backtracking are naturally recursive.

Example

Recursive rendering cannot be paused, so React Fiber replaces it with a loop that follows child, sibling and return pointers.

Related terms

Taught in

References

Certification courses