The mystery argument

Consider this:
bc.. window.setTimeout(foo,100,”bar”,”baz”);
function foo(){
for (var arg = 0;arguments[arg];arg++){
alert(arg+”: “+arguments[arg]);
p. What should the value of @arguments.length@ be?

The documentation I use every day, suggest that you can pass any number of arguments in a @window.setTimeout@ and have them available from the @arguments@ array. However, that is not the case:
h3. Internet Explorer
Internet Explorer won’t let me pass arguments to a setTimeout, and makes @arguments.length == 0;@ — which is fair enough, The “MSDN documentation”: suggests that only the optional @lang@ parameter is allowed
h3. Opera
Opera tells me that @arguments.length == 2@ which is exactly what I expected.
h3. Mozilla/Firefox
And along comes the mystery: The “Gecko DOM Reference”: states that no optional arguments are allowed. Supporting “language” doesn’t make much sense when you have only one scripting language.
However, in Gecko, arguments.length == 3 — where the first two values are arguments[0] == "bar"; and arguments[1] == "baz";. The last one, however is a mystery: It returns a numeric value. The value of arguments[2] is 10, 13 and 7, respectively.
Can anyone please enlighten me and tell me what this third value of the arguments array is, why it’s there and where it’s documented?

Previous Post
Leave a comment


  1. jaap

     /  2005-07-18

    Could it be the timeOut ID? Try alerting the return value of the setTimeout call and compare it with arguments[2].

  2. Nope, it is not the timeout ID. An example run reveals that the timeout ID is 3, while the value of the last argument is 76791834.

  3. This might be something called timeout lateness (also read comments #5 and #7). Bugs 299476 and 243630 might also be of interest.

  4. This parameter is one of the things I really don’t see the sensibility in passing: No live site I know of depends on this, and there is nothing useful to be done with this, except perhaps benchmarking Mozilla itself.