展开全部
setInterval:
The real delay between func calls for setInterval is less than in the code!
That’s normal, because the time taken by func’s execution “32313133353236313431303231363533e59b9ee7ad9431333433656666consumes” a part of the interval.
It is possible that func’s execution turns out to be longer than we expected and takes more than 100ms.
In this case the engine waits for func to complete, then checks the scheduler and if the time is up, runs it again immediately.
In the edge case, if the function always executes longer than delay ms, then the calls will happen without a pause at all.
setTimeout:
The recursive setTimeout guarantees the fixed delay (here 100ms).
That’s because a new call is planned at the end of the previous one.
举例: