SetTimeoutReturnsCallbackResult
DRAFT

Misconception:

Calling setTimeout(foo, ms) calls foo after ms milliseconds and returns the value returned by foo.

Incorrect

SetTimeout returns the value returned by the callback function

Correct

SetTimeout returns an identifier of the newly scheduled timer

Correction
Here 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.

Language

JavaScript

Concepts

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.