In javascript, is there any different between these two:
// call MyFunction normal way
MyFunction();
// call MyFunction with setTimeout to 0 //
window.setTimeout('MyFunction()', 0);
The reason I asked was because recently came across the situation where the code only works if I use setTimeout(0)
to call the function.
To my understanding, setTimeout(0)
is exactly same as calling a function directly because you dont set any delay. But from what I see how it works in the code, setTimeout(0)
seems to get executed last.
Can someone clarify exactly how setTimeout(0)
really get called in order of the rest of other function call?