Many programming languages have a sleep function that will delay a program’s execution for a given number of seconds. This functionality is absent from JavaScript, however, owing to its asynchronous nature. In this article, we’ll look briefly at why this might be, then how we can implement a sleep function ourselves. We’ve rewritten this popular guide from scratch to provide the best and most up-to-date advice. This article was updated in November 2019. Understanding JavaScript’s Execution Model Before we get…