
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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