Learn Intermediate JavaScript_ Async-Await Cheatsheet _ Codecademy
Learn Intermediate JavaScript_ Async-Await Cheatsheet _ Codecademy
Async-Await
Promise.all([promise1, promise2,
promise3]).then(function(values) {
console.log(values);
});
// expected output: Array [5, 44, "foo"]
Creating async Function
JavaScript async functions uses try...catch let json = '{ "age": 30 }'; // incomplete
statements for error handling. This method allows shared
data
error handling for synchronous and asynchronous code.
try {
let user = JSON.parse(json); // <-- no
errors
alert( user.name ); // no name!
} catch (e) {
alert( "Invalid JSON data!" );
}
The aysnc and await Keywords
Print Share