The jQuery source features uses of setTimeout
with both 0
and 1
as second argument. I\'m under the impression that they both mean &quo
For reasons why setTimeout(fn, 0) or setTimeout(fn, 1) is needed, check out Why is setTimeout(fn, 0) sometimes useful?.
In essence, it means that this method is not very urgent to execute compared to other browser tasks like page rendering. Moreover, the JavaScript code will run after the waiting tasks are over.
Practical wise, there is no difference between using 0 or 1. This is just programmer's choice. Ideally the number chosen by coders is below 4 which may be due to the reason pointed out by Amaan.
BTW, for basic information on JavaScript timers, refer to http://ejohn.org/blog/how-javascript-timers-work/