Hacker News new | ask | show | jobs
by indubitably 4208 days ago
Does `setTimeout` have a default value for the time?
1 comments

setTimeout with no timeout argument simply schedules the provided function for when the interpreter is next idle. Underscore.js wraps a similar unqualified call in _.defer (last i checked, anyway; they might now provide it with a very small number or 0 for the timeout).

Edit: in both cases the result is the same in most browsers.

It's clamped to 4. You can't go lower than that.

There is `setImmediate` for making something run the very next cycle. However, only IE10+ supports it and the other browser vendors are against it. You can use abuse `postMessage` to get a similar effect.