Javscript async/await
A Complete Guide:
Thread🧵
A Complete Guide:
Thread🧵
📌We use the async keyword with a function to represent that the function is an asynchronous function.
📌The async function returns a promise.
🎯For JavaScript Promises you can go through
📌The async function returns a promise.
🎯For JavaScript Promises you can go through
➡️In the above program, a Promise object is created and it gets resolved after 4000 milliseconds. Here, the asyncFunc() function is written using the async function.
➡️The await keyword waits for the promise to be complete (resolve or reject).
⏺️let result = await promise;
➡️The await keyword waits for the promise to be complete (resolve or reject).
⏺️let result = await promise;
📌Hence, JavaScript is displayed only after promise value is available to the result variable.
📌In the above program, if await is not used, JavaScript is displayed before Promise resolved.
📝Note: You can use await only inside of async functions.
📌In the above program, if await is not used, JavaScript is displayed before Promise resolved.
📝Note: You can use await only inside of async functions.
If you enjoyed reading this thread, please do the following:
1. Like the thread❤️
2. Retweet the first tweet.🔃
3. Follow me and enable notifications: ✅
@CodeMarch
Thank you for reading all the way through.
1. Like the thread❤️
2. Retweet the first tweet.🔃
3. Follow me and enable notifications: ✅
@CodeMarch
Thank you for reading all the way through.
✨ JavaScript for Starters: The Complete Guide ✨
➱ JavaScript Roadmap 2022
➱ JavaScript Fundamentals with Exp.
➱ 50+ Programs to practice with Soln.
➱ 50+ Project Ideas
➱ 25+ Projects Code
Grab it NOW.
codemarch.gumroad.com
➱ JavaScript Roadmap 2022
➱ JavaScript Fundamentals with Exp.
➱ 50+ Programs to practice with Soln.
➱ 50+ Project Ideas
➱ 25+ Projects Code
Grab it NOW.
codemarch.gumroad.com
Loading suggestions...