What is a closure?
A closure is a feature in JavaScript where an inner function has access to the outer (enclosing) function’s variables.I think, that closures are very handy for recursive call.
What is a recursion?
Simply said, the process in which a function calls itself.When you create a recursive function, keep in mind that there must be an escape from the recursive function, otherwise you will get into an infinite loop.
Below I created a function, which call yourself. Recursion can be very complex, but the principle is the same.
Try it yourself:
No comments:
Post a Comment