Hello. This is me again with strange clarification of the steps of the tutorial.
This is where
setInterval()
comes in. This works in a very similar way tosetTimeout()
, except that the function you pass as the first parameter is executed repeatedly at no less than the number of milliseconds given by the second parameter apart, rather than once. You can also pass any parameters required by the function being executed as subsequent parameters of thesetInterval()
call.
let i = 1;
setInterval(function run() {
console.log(i);
i++
}, 100);
- The example using
setInterval()
does things somewhat differently. The interval you chose includes the time taken to execute the code you want to run in. Let’s say that the code takes40
milliseconds to run — the interval then ends up being only60
milliseconds.
The first quote says that the interval is always no less than that specified by the second parameter of setInterval().
The second quote indicates that it is possible that the interval will be less than the second specified parameter of setInterval().
Can someone explain this point, please?