Async-Await
Learn about asynchronous programming and leverage promises in JavaScript.
StartKey Concepts
Review core concepts you need to learn to master this subject
Resolving JavaScript Promises
Asynchronous JavaScript function
Async Await Promises
Using async await syntax
JavaScript async…await advantage
Async Function Error Handling
JavaScript aysnc await operator
Resolving JavaScript Promises
Resolving JavaScript Promises
let promise1 = Promise.resolve(5);
let promise2 = 44;
let promise3 = new Promise(function(resolve, reject) {
setTimeout(resolve, 100, 'foo');
});
Promise.all([promise1, promise2, promise3]).then(function(values) {
console.log(values);
});
// expected output: Array [5, 44, "foo"]
When using JavaScript async...await
, multiple asynchronous operations can run concurrently. If the resolved value is required for each promise initiated, Promise.all()
can be used to retrieve the resolved value, avoiding unnecessary blocking.
Async Await
Lesson 1 of 1
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory