VOOZH about

URL: https://dev.to/ali_hamza_589ec7b3eb6688d/day-29-of-learning-mern-stack-4g8j

⇱ Day 29 of learning MERN Stack - DEV Community


Hello Dev Community! 👋

It is officially Day 29 of my journey to master the MERN stack! Tomorrow marks a full month of consistency, and today I wrapped up the absolute final part of Lecture 10 in Apna College's JavaScript playlist with Shradha Didi. We focused on the modern industry standard for asynchronous execution: Async/Await and IIFE.

Yesterday, we flattened our code using Promise Chaining. Today, I learned the syntax that senior developers use daily to make async operations read like simple, linear code.


🧠 Key Learnings From JS Lecture 10 (Async/Await)

Async/Await is not a new concept under the hood; it is a beautiful syntax wrapper (syntactic sugar) built on top of native Promises.

1. The async & await Keywords

  • async: Placed before a function declaration, it automatically forces that function to return a Promise.
  • await: Can only be used inside an async function. It pauses the function's execution line-by-line until the target Promise resolves or rejects.

This completely eliminates the need for chaining .then() blocks! Look how clean this layout is:


javascript
async function getAllData() {
 await getData(1);
 await getData(2);
 await getData(3);
 console.log("All data fetched linearly!");
}