setInterval passes a "phantom" parameter to the function it calls

RESOLVED DUPLICATE of bug 394769

Status

()

defect
RESOLVED DUPLICATE of bug 394769
8 years ago
8 years ago

People

(Reporter: buzuzyma, Unassigned)

Tracking

6 Branch
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Reporter

Description

8 years ago
User Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110812234425

Steps to reproduce:

When you set an interval, and pass a function to it, the function will receive what I call a "phantom parameter". This is a parameter that has no apparent origin and that should not be expected. Quick way to reproduce:

var a = function(p){alert(p);}; intervalID = setInterval(a, 2000);


Actual results:

the function received a parameter that was not supposed to be there. This causes problems when the expected parameter is used inside the function.


Expected results:

No parameter should be received.

Comment 1

8 years ago
This is a documented feature:
https://developer.mozilla.org/en/window.setInterval#Callback_arguments
"setInterval() will pass the number of milliseconds late the callback was called into the callback function"
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 394769
You need to log in before you can comment on or make changes to this bug.