Recursion
An algorithmic pattern where a function calls itself in some cases.
Examples
function getLinkedListLength(node) {
if (!node) {
return 0;
}
// recurse
return 1 + getLinkedListLength(node.next);
}
function fibonacci(n) {
if (n < 3) {
return 1;
}
// recurse
return fib(n - 1) + fib(n - 2);
}