๐๐ฎ๐ ๐ฎ๐ณ ๐ข๐ณ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด ๐ ๐๐ฅ๐ก ๐ฆ๐๐ฎ๐ฐ๐ธ
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