I try to make a website without updating the page at all. The main function mainController () loads content with ajax (ajax?); in this content there is a link by which with the help of another function (if the condition is fulfilled), again, mainController () is called. The question is - will not these multiple function calls from functions clutter up the function stack and overload the RAM? After all, functions do not return anything (procedures), but only for some condition they call another function.
2 answers
In short, then - no, it will not.
A little more detailed.
there is a link in this content
Then the call to mainController
is possible only after a click (eg event'a), there is no recursion, no recursion - there is no problem described by you.
|
Chance to catch stack overflow
in this situation is. Another thing is that for this, depending on the browser, you may need several thousand recursive calls. It is best to avoid this situation. If the recursive call goes at the very end of the function, then you can try calling the function via setTimeout
. But this is a perversion. Try to revise your architecture so that it does not need to call the function recursively.
|