what is the accuracy of setTimeout and setInterval timing? What is the minimum timing millisecond? Is there anything you need to pay attention to?
what is the accuracy of setTimeout and setInterval timing? What is the minimum timing millisecond? Is there anything you need to pay attention to?
setTimeout and setInterval have no precision to speak of, they just throw the task into the event loop of js, and it may be their turn to execute.
setTimeout (() = > {xxx}, 0);
will only be executed for you as soon as possible, but cannot be guaranteed to be executed immediately
refer to
" event loop "
actual delay ratio Reason for setting the value longer
if you only talk about the precision of parameters, millisecond
refer to API document
computer monitors are generally refreshed at 60Hz, redrawn 60 times per second.
therefore, if you want to achieve the smoothest animation, the best interval is 1000ms 16.6ms 60, which is about equal to the animation.
Previous: How to debug? the php backend when the front end is separated from the front end?
Next: Laravel cannot get session value for cross-domain POST request when csrf is turned off