Delay, Sleep, Pause, & Wait in JavaScript
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.