I will be brief, let's take easy examples. I have these two functions:
function first() {
alert("Function One");
}
function second() {
alert("Function Two");
}
I would like to pass from function first() to second() without doing this:
function first() {
alert("Function One");
second();
}
function second() {
alert("Function Two");
first();
}
Because I would create a stack overflow (like first() is calling second() inside of itself, then second() that is in first() and is calling first() again and so on, creating an endless loop that is unwanted)
How could I simply "pass" from a function to another? Ask if you need more informations.
Thank you all.
You can simply call the two functions in a loop:
while (true) {
first();
second();
}
But infinite loops like this aren't good in Javascript, this will lock up the browser. It's not clear what you're really trying to do. This will just avoid the stack overflow from recursion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With