The doMoreStuff() function recursively calls the doStuff() function.
That's not really mutual recursion, as doStuff
doesn't call doMoreStuff
- it only sets it up as a handler to be called.
Does JavaScript manage the memory properly
Yes. Asynchronous "recursion" (sometimes dubbed pseudo-recursion) does not grow the call stack, it's much like tail recursion.