SetTimeoutReturnsCallbackResultDRAFT
Calling setTimeout(foo, ms)
calls foo
after ms
milliseconds and returns the value returned by foo
.
SetTimeout returns the value returned by the callback function
SetTimeout returns an identifier of the newly scheduled timer
CorrectionHere is what's right.
With setTimeout
we schedule the asynchronous execution of a given function. This means that the function is not being executed right now, but will be later in the future. For this reason, it is impossible that the value returned by setTimeout
is the result of the function passed as a first argument.
The setTimeout
API actually returns something, but it has nothing to do with the result of the function. It is an identifier through which one can possibly cancel the planned execution of the function.