Say that I have the following code:
function testA {
setTimeout(\'testB()\', 1000);
doLong();
}
function testB {
doSomething();
}
function doLong() {
The first of your guesses is the correct one:
testB() is queued up to execute after doLong() and anything else it called have finished.
If it takes more than one second for testA
to finish, testB
will simply have to wait.
Also, you should write setTimeout(testB, 1000)
rather than setTimeout('testB()', 1000)
. Sending a string to setTimeout is, like using eval
, generally considered evil and will make you enemies ;)