Repaso
EspaƱol

What is a Promise in JavaScript?

Options

  1. A guaranteed value that is available right away
  2. An object for a value that arrives later, or an error (Correct option)
  3. A special type of loop that is used for async code
  4. A CSS animation that waits for events on the page

Answer

An object representing a value that will be available later (or an error), from an async operation like a network request

Why

Operations like fetch(url) take time. Instead of freezing the page, they immediately return a Promise: a placeholder for the future result.

A promise is pending, then becomes fulfilled (with a value) or rejected (with an error).

You handle it with .then(...) / .catch(...) or, more readably, with await inside an async function.

Remember

Promise = placeholder for a future result.

Key terms

Practice this question in Repaso