

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
Promises are the cleanest (but not the only) way to handle the common scenario where we need to make requests to a server, which is typically done via an HTTP request. JavaScript's built-in fetch() function (that we'll cover in a later course) returns a promise.
Almost every time you use a promise it will be to handle some form of I/O. I/O, or input/output, refers to when our code needs to interact with systems outside of the (relatively) simple world of local variables and functions.
Common examples of I/O include:
Promises help us perform I/O without forcing our entire program to freeze up while we wait for a response.