Languages
[Edit]
EN

JavaScript - measure elapsed time between setInterval() intervals

0 points
Created by:
elmer
646

In this article, we would like to show you how to measure elapsed time between setInterval() intervals using JavaScript.

Quick solution:

Warning:

This API does not guarantee that timers will run exactly on schedule. Delays due to CPU load, other tasks, etc, are to be expected.

 

Alternative solution

Edit

In this example, as an alternative solution, we use performance.now() to measure the time elapsed between intervals.

 

References

  1. setInterval() - Web APIs | MDN
  2. performance.now() - Web APIs | MDN
  3. HTML Standard
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join