Reputation: 8330
This SO answer makes a call to setTimeout
with four arguments.
setTimeout(self.process1, 0, self, u);
This confuses me. The documentation I've seen for setTimeout
only uses two arguments, not four.
What do the last two arguments do?
Upvotes: 1
Views: 969
Reputation: 262979
Quoting the documentation on MDN:
Syntax
var timeoutID = window.setTimeout(func, delay, [param1, param2, ...]);
Note that passing additional parameters to the function in the first syntax does not work in Internet Explorer.
Upvotes: 3
Reputation: 9092
This function has two signatures
var timeoutID = window.setTimeout(func, delay, [param1, param2, ...]);
var timeoutID = window.setTimeout(code, delay);
Note that passing additional parameters to the function in the first syntax does not work in Internet Explorer.
Note found in MDN in regards to what these extra parameters are for:
Prior to Gecko 13 (Firefox 13.0 / Thunderbird 13.0) , Gecko passed an extra parameter to the callback routine, indicating the "actual lateness" of the timeout in milliseconds. This non-standard parameter is no longer passed.
The first signature (with more than two params) is not supported by all browsers so my personal recommendation is to avoid it.
Upvotes: 2