Posts

Showing posts from July, 2020

JavaScript: Async functions (async/await)

Image
JavaScript: Async functions (async/await) I am sure that many of you are using async and await already. But, I think it deserves a little more attention.   Every one should remember Mozilla docs is your friend. Here is the MDN definition for async and await: async: “An asynchronous function is a function which operates asynchronously via the event loop, using an implicit Promise to return its result. But the syntax and structure of your code using async functions is much more like using standard synchronous functions.”   await:  “An async function can contain an await expression that pauses the execution of the async function and waits for the passed Promise's resolution, and then resumes the async function's execution and returns the resolved value. Remember, the await keyword is only valid inside async functions.”   Confused………..   Lets put this defination in this way   A function defined as async is a function that can perform asynchronous actions but still look synchro