Async/Await
async/await is a new syntax for writing asynchronous code in JavaScript. It is built on top of promises and makes asynchronous code look and behave more like synchronous code.
async: Theasynckeyword is used to declare an async function. Async functions always return a promise.await: Theawaitkeyword can only be used inside an async function. It pauses the execution of the function until the promise is fulfilled or rejected.
async function myAsyncFunction() {
try {
const result = await myPromise;
console.log(result);
} catch (error) {
console.error(error);
}
}