- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the JavaScript version of sleep()?
The JavaScript version of sleep() is “await”. The await feature pauses the current aync function.
Example
You can try to run the following code to implement sleep in JavaScript
<!DOCTYPE html> <html> <body> <script> function setSleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function Display() { document.write('Wait for 5 seconds!'); await setSleep(5000); document.write('After 5 seconds!'); } Display(); </script> </body> </html>
- Related Articles
- What is javascript version of sleep()?
- JavaScript Sleep() function?
- Is the second string a rotated version of the first string JavaScript
- What is a long winter sleep called?
- Sleep in JavaScript delay between actions?
- How can you detect the version of a browser using Javascript?
- How to install the specific version of the PowerShell module version?
- What is the use of a multi-version compatible jar in Java 9?
- Which is the selenium latest version?
- Modified version of summing an array with recursion in JavaScript
- What are the foods that can help sleep well?
- With JavaScript how can I find the name of the web browser, with version?
- The Wonder Called Sleep
- How do I check what version of Python is running my script?
- How to get the application name and version information of a browser in JavaScript?

Advertisements