AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Node js sleep function11/1/2023 So, whether you're just getting started with JavaScript or you're looking for a better way to handle waiting for pages to load, any of these functions can be useful. ![]() If you need to call a function after a specific amount of time, then the setTimeout() function might be a better choice.Īnd if you need to call a function at regular intervals, then the setInterval() function might be a better choice. When a timer's function is called varies depending on which method was used to create the timer and what other work the Node.js event loop is doing. If you only need to pause the program for a specific amount of time, then the wait() function might be the best choice. A timer in Node.js is an internal construct that calls a given function after a certain period of time. Now that you know about some of the alternatives to the wait() function, you might be wondering which one you should use. One difference is that the setInterval() function will continue to call the function at specified intervals until it is explicitly stopped. We assume that you are familiar with the prerequisites as covered in the above-mentioned link. It also returns a value that can be used to cancel the timer. Node.js Strapi. ![]() ![]() Like setTimeout(), the setInterval() function is also non-blocking.
0 Comments
Read More
Leave a Reply. |