Why can I not pass a function call (rather than a function reference or an anonymous function) to setTimeout()?

This is because of the order of execution. If you pass a function call to setTimeout, the function will be executed immediately, i.e. the function is put on javascript’s execution stack immediately.

If you pass a function name, i.e. a reference to a function, the function is only put in the javascript thread’s execution stack once the timer finishes.

Leave a Comment