Promptles
Programming Basics

async / await

intermediate

Definition

Two JavaScript words that let code wait for a slow step, like loading orders from the internet, before moving on, without freezing the rest of the app. `async` marks a function that will wait, and `await` marks the exact step to wait for (usually a promise, a placeholder for a result that isn't ready yet).

In the wild

`const orders = await loadOrders();` waits until the orders arrive before showing them. Forget the `await` and you get the placeholder instead of the orders.

More from Programming Basics