SetTimeout0IsSynchronousDRAFT
Calling setTimeout(f, 0)
is equivalent to a synchronous call of the function f
.
Scheduling the execution of a function after 0 milliseconds with setTimeout is equivalent to a synchronous call
Scheduling the execution of a function after 0 milliseconds with setTimeout is not equivalent to a synchronous call
CorrectionHere is what's right.
The setTimeout
method is used to schedule the execution of a function after a certain number of milliseconds. Even though 0
(and even negative numbers) can be passed as a second argument, this does not mean that the function is going to be called immediately. On the contrary, setTimeout
“enqueues” the event of executing the supplied function, which can be executed not before the next event cycle.