

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Synchronous vs. Asynchronous
incomplete
2: Why Async?
incomplete
3: Promises
incomplete
4: Why Promises?
incomplete
5: Await
incomplete
6: Async Keyword
incomplete
7: then vs. await
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
We try to mostly write synchronous code whenever possible because it's easier to keep track of, and therefore leads to fewer bugs. But sometimes we need our code to be asynchronous. For example, whenever you update your user settings on a website, your browser needs to communicate those new settings to the server. The time it takes your HTTP request to physically travel across all the wiring of the internet can be anywhere from 10-1000 milliseconds (give or take).
It would be excruciating if your webpage froze while waiting for every network request to finish. By making network requests asynchronously, the webpage can continue to execute other code while waiting for the HTTP response to come back.