- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
How to run functions iteratively with async await in JavaScript?
You can use keyword async as well as await. Following is the code −
Example
async function test(i) { while (i <= 10) { await demo(" Call Demo1()"); await demo(" Call Demo2()"); i++; } } async function demo(value){ console.log(value); } test(1);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo73.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo73.js Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2() Call Demo1() Call Demo2()
Advertisements