Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The mystery arguments passed by setTimeout in Firefox [duplicate]

Possible Duplicate:
Firefox setTimeout(func, ms) sending default parameters to callback

I have been wondering this for a long time. When I type in the following line in FF, then I get:

var timer = setTimeout(function () {console.log(arguments)}, 500);

arguments outputs an array with a random number in it, and this number is different from the value of the timer. When I try on Chrome, the arguments is an empty array.

Anyone has noticed this?

like image 695
Grace Shao Avatar asked Sep 26 '11 21:09

Grace Shao


1 Answers

From https://developer.mozilla.org/en/window.setTimeout:

Gecko passes an extra parameter to the callback routine, indicating the "lateness" of the timeout in milliseconds.

like image 187
Daniel Brockman Avatar answered Sep 30 '22 08:09

Daniel Brockman