Why are the Firefox setInterval callback arguments different from other browsers?

I tested this script in every browser in Win 7. It works not only with Firefox (version 3.6.13).

The warning field returns "undefined" in all browsers except Firefox, which returns a random number. Here is the script

function nextSlide(nav){
    alert(nav);
}

jQuery(function(){
    var set = setInterval(nextSlide, 2000); 
});

Here is a live demo

+3
source share
2 answers

An additional argument is the number of milliseconds for which the callback was called. From the doc:

Callback arguments

setInterval() , , , - . , .

:

var set = setInterval(function() { nextSlide(); }, 2000);
+5

Mozilla.

Firefox. WindowTimers - , , HTML5, - . , ...

handle = window. setInterval ( [, timeout [, arguments]])

     

- . .

, Firefox , arguments.length 1, " ".

, HTML4 defacto- - " ", , , , , , Firefox , . /.

Edit:

Firefox pass-through, Neil arguments.length, , , "" - arguments.length ( ).

: / arguments.length . ( ).

+1

Source: https://habr.com/ru/post/1791706/


All Articles