Java has Thread.sleep(2000), Python has time.sleep(2), Go has time.Sleep(2 * time.Second). But there are some JavaScript native functions (timers) which allow us to delay the execution of arbitrary instructions: setTimeout() setInterval() setImmediate() requestAnimationFrame() These methods are not a part of JavaScript specification. An integer indicating the number of milliseconds to delay execution of the next item in the queue. setInterval allows us to run a function repeatedly, starting after the interval of time, then repeating continuously at that interval. A block of JavaScript code is generally executed synchronously. James Hibbard explains the pitfalls of implementing a sleep function in JavaScript, and digs into solutions for dealing with JavaScript timing issues. I say that to each their own and one rule can never dictate anything in this […] .delay( duration [, queueName ] )Returns: jQuery. setInterval ( function, milliseconds) Same as setTimeout (), but repeats the execution of the function continuously. JavaScript does not have a native sleep function, but thanks to the introduction of promises (and async/await in ES2018) we can implement such feature in a very nice and readable way, to make your functions sleep: version added: 1.4.delay( duration [, queueName ] ) duration. The infamous sleep, or delay, function within any language is much debated. Type: Integer. The two key methods to use with JavaScript are: setTimeout ( function, milliseconds) Executes a function, after waiting a specified number of milliseconds. Description: Set a timer to delay execution of subsequent items in the queue. Some will say that there should always be a signal or callback to fire a given functionality, others will argue that sometimes an arbitrary moment of delay is useful. setTimeout allows us to run a function once after the interval of time.