There are a lot of requirements that require timers, like the usual countdown, though it's simple, but there's a lot of bad implementations.
A timer can only provide the ability to trigger a queue at a certain point in time, and the point at which it is triggered is indeterminate.
For example, to increment or decrement a variable in a timer a behavior is not suitable for the countdown this implementation of the following code
var t =settinterval (function (){ --t;});
This code countdown is a big hole. If you switch the window to the countdown function, you're just a jerk.
Plus the triggering interval does not guarantee that if a longer message queue is plugged in, then your countdown will be postponed again!
So a countdown like this program is best based on time to calculate the following
var t = Date.now () +23333; Settinterval (function (_t){ if(Date.now ()-t>=0 ) //....});
In fact, we should use settimeout to replace setinterval setinterval can achieve settimeout can do.
Those animations that are non-CSS3 transition animate are the ones that depend on the timer where the real-time animation is manipulated by incrementing the decrement variable to be able to switch the window is also not much related and convenient.
But some features have to be calculated on a time-based basis!
For example, the upcoming react video barrage playback system The coordinate position of each projectile must be the F (t) function
This post doesn't have much to do with the above text (to improve the dream reach rate) ~
Do not rely on timers in time