DEV Community

Discussion on: ⭐️🎀 JavaScript Visualized: Promises & Async/Await

Collapse
charanweb profile image
CHARAN

I got a difference answer when i tried the last code:
Async/await executing the next lines but saving in memory not showing in the output ,until await got the result. And its working synchronously. it shows first await result and executing line by line.


const x = Promise.resolve("Async function")

async function getme(){
 console.log("Before Async")
 const res = await x
 console.log(res)
 console.log("After Async")
}
getme()
//results
 Before Async
 Async function
 After Async
Promise {<fulfilled>: undefined}
Enter fullscreen mode Exit fullscreen mode