Asynchronous JavaScript
Asynchronous Study Path
Learn Asynchronous JavaScript in the Right Order:
Step 1
Async Programming
JavaScript executes code one line at a time. Each line must finish before the next line can run.
Asynchronous is how JavaScript can allow some code to run in the background, and let their results be handled when they are ready.
Step 2
Async Timeouts
The setTimeout() method schedules a function to run after a delay in milliseconds.
It is an asynchrounus operation used to delay code execution without freezing the browser.
Step 3
Async Callbacks
A callback is a function that runs later.
The name "callback" stems from the idea that the function will "call you back" later when it has finished its task.
Step 4
Async Promises
JavaScript Promises were created to make asynchronous JavaScript easier to use.
A Promise object represents the completion or failure of an asynchronous operation.
A Promise can be in one of three exclusive states: pending, rejected or fulfilled.
Step 5
Async Await
async and await make promises easier.
You still use promises, but you write the code like normal step by step code.
async makes a function return a Promise
await makes a function wait for a Promise
Step 6
Async Fetch
Modern apps use async code to get data.
fetch() is the modern way to request data from a server.
fetch() is asynchronous and returns a promise.
Step 7
Async Debugging
Asynchronous bugs are difficult because the code runs later.
This chapter shows practical ways to debug fetch(), promises, async and await.