Recursive function is a function which calls itself again and again. A recursive function must have at least one condition where it will stop calling itself.
- A recursive function in general has an extremely high time complexity.
- A recursive function generally has smaller code size .
- In some situations, only a recursive function can perform a specific task.
function recurFun() {
//your code goes here()
recurFun();
}
recurFun();
“recurFun()” is a JavaScript Recursive Function which invokes itself inside its body.