The second argument of setInterval() is whatever value is set to blink_speed, so this is going to alternate (eternally) the SPAN tag contents between hidden and visible every second (1000 ms = 1 sec).
Yes, the function() is the first argument for setInterval() (the code to run) which is repeated as often as the second argument is set for in milliseconds.
And AFAIK, I believe that “unnamed function” or “anonymous function” is correct.
It doesn’t get passed to blink() - it’s being SET inside the blink function, called from the body “onload” attribute. You could pass it to blink, then pass that on as the second argument, if you wanted.
When it’s spread out across many lines, it can be a bit difficult to read. However, if you put it all on one line:
blink_speed = 1000;
var t = setInterval(function () { var ele = document.getElementById(‘Foo’); ele.style.visibility = (ele.style.visibility == ‘hidden’ ? ‘’ : ‘hidden’); }, blink_speed);
Red is the variable that is being set and the beginning/end of setInterval().
Green is the first argument, the function.
Purple is the second argument, the time in milliseconds that the function will be triggered.
The first is the function you want to have run at regular intervals.
The second is a time interval in milliseconds.
It knows that the time is in milliseconds because that is what the setInterval function expects the second parameter to be.
If you try to pass an invalid parameter to the function then the function will attempt to convert what you pass to what it expects. So if you passed a string as the first parameter it would eval() the string in an attempt to convert it to a function. If you passed hamburgers as the second parameter it would attempt to convert that to milliseconds.