This is an example from a tutorial about setInterval, but it doesn't explain it enough for my newbie. I would appreciate it if you could answer these questions.
i) means a timer of 1000 milliseconds means that the moveElement function will fire every second? In other words, after it starts, will it wait 1 second and then start it again?
ii) is the purpose of moveElement to move the "redBox" 10 pixels to the left each time it starts? why "px" is used in a function
iii) after moveElement is first run, does the new value for x (x + = 10) replace the value 0 in var x = 0? that is, it is stored outside the function in the variable x at the top of the program?
var x = 0; setInterval(moveElement,1000); function moveElement() { x+=10; var left = x + "px"; document.getElementById("redbox").style.left=left;
mjmitche
source share