SyntaxStudy
Sign Up
JavaScript Beginner 3 min read

Promises Summary

Promises Summary

Promises represent future values in three states. Async/await is syntactic sugar over promises. Use Promise.all for parallel work, Promise.race for timeouts, AbortController for cancellation, and always handle errors.

Example
async function dashboard(userId) {
  const [user, posts] = await Promise.all([
    api.getUser(userId),
    api.getPosts(userId),
  ]);
  return { user, posts, loadedAt: Date.now() };
}
Pro Tip

async/await reads synchronously but executes asynchronously — the best of both worlds.