
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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()
- Related Articles
- Async/Await Functions in JavaScript
- Explain Promise.any() with async-await in JavaScript?
- Explain Promise.race() with async-await in JavaScript?
- Explain Promise.all with async-await in JavaScript?
- Explain Promise.allSettled() with async-await in JavaScript?
- How to run a function after two async functions complete - JavaScript
- How to use await outside of an async function in JavaScript?
- Async & await keyword in C#
- Async and Await in Dart Programming
- Sync vs Async vs Async/Await in fs-extra - NodeJS
- Promises Callbacks And Async/Await
- Asynchronous programming in C# using Async and Await keyword
- Can Python functions run in html as javascript does?
- How to run Python functions in Eclipse command line?
- How to run multiple async tasks and waiting for them all to complete in C#?

Advertisements