NOTE: This is probably outdated information as the secret timeout was removed many years ago as per bugzilla #394769.

You can actually add parameters to the setTimeout call:

function foo(){
  for (var arg = 0;arguments[arg];arg++){
    alert(arg+": "+arguments[arg]);

In this case, the length of the arguments will be 3, and the contents will be:

arguments[0] == "bar";
arguments[1] == "baz";
arguments[2] == 12415; // Changes with every new window?

The mystery question is: What is arguments[2]?


It's supposed to indicate how late the timeout is. Here's the code that initializes it:
     // Add a "secret" final argument that indicates timeout lateness
     // in milliseconds
     LL_SUB(lateness64, now, timeout->mWhen);
     LL_L2I(lateness, lateness64);
     lateness = PR_IntervalToMilliseconds(lateness);
     timeout->mArgv[timeout->mArgc] = INT_TO_JSVAL((jsint) lateness);
This secret argument doesn't always have sane value for me, though. --Nickolay 03:46, 18 Jul 2005 (PDT)
By the way, feel free to add the information about the alternative syntax (passing function object as first param), and about the possibility of passing additional arguments to the callback.
Added it myself. --Nickolay