𝗗𝗮𝘆 𝟮𝟳 𝗢𝗳 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗠𝗘𝗥𝗡 𝗦𝘁𝗮𝗰𝗸
I studied Asynchronous JavaScript today. This topic is a top interview subject. I followed Lecture 10 from the Apna College series.
Before today, my code ran one line after another. This is synchronous execution. If one line takes five seconds, the whole program stops. This blocks the user.
Asynchronous JavaScript changes this. It lets time-consuming tasks run in the background. The rest of your script keeps running.
I practiced with setTimeout. This utility runs code after a set delay. I noticed that code written after a timeout often runs first. This proves JavaScript does not wait for every task to finish.
I also studied Callback Hell. This happens when you nest many functions inside each other.
I ran these practice exercises:
- Simulated fetching user IDs from a server.
- Nested multiple data fetches to create a pyramid structure.
- Observed how difficult the code became to read and debug.
Large nested structures make code hard to maintain. This is why modern developers use better tools.
Tomorrow I start on the solutions:
- Promises with .then() and .catch().
- Async/Await syntax for cleaner code.
To my fellow learners: Did nested callbacks confuse you at first? To senior developers: Do you still work on old codebases that use these structures?
My practice code is on GitHub.
Source: https://dev.to/ali_hamza_589ec7b3eb6688d/day-27-of-learning-mern-stack-1cgj