otnj2ee
08-05-2008, 11:38 PM
In a javascript, assume there are three sequencial lines:
var a = "1st line";
setTimeout("2ndLine()", 1000);
var b ="3rd line"
...
function 2ndLine(){
...
}
Obviously, the order of the execution is:
var a = "1st line";
then, setTimeout("2ndLine()", 1000);
Now once it hits this line, will it call the setTimeout function and wait for 1000ms, then execute the function 2ndLine(), then finally the var b ="3rd line"? OR
it call the setTimeout function, put the 2ndLine() on hold (for 1000ms), but at the mean time, go ahead execute the 3rd line, i.e., var b ="3rd line" (so in this case, it is possible for the execution of 2ndLine() to happen after the 3rd line)?
Thanks
Scott
var a = "1st line";
setTimeout("2ndLine()", 1000);
var b ="3rd line"
...
function 2ndLine(){
...
}
Obviously, the order of the execution is:
var a = "1st line";
then, setTimeout("2ndLine()", 1000);
Now once it hits this line, will it call the setTimeout function and wait for 1000ms, then execute the function 2ndLine(), then finally the var b ="3rd line"? OR
it call the setTimeout function, put the 2ndLine() on hold (for 1000ms), but at the mean time, go ahead execute the 3rd line, i.e., var b ="3rd line" (so in this case, it is possible for the execution of 2ndLine() to happen after the 3rd line)?
Thanks
Scott