Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 999 Bytes

README.md

File metadata and controls

37 lines (24 loc) · 999 Bytes

34. Promises

Represent eventual success or failure.

Learn

  • Promise
  • then
  • catch
  • finally
  • Promise.all

How it works

A promise settles once as fulfilled or rejected. then transforms its successful value and returns another promise; catch handles rejection. Promise.all combines independent operations and rejects when one fails. Always return a promise from a callback when a chain should wait for it.

Common mistake

Ignoring a rejected promise can produce an unhandled rejection and missing UI feedback.

Guided challenge

Combine two delayed values and show success and failure paths.

Run the example

Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.

Completion check

  • Explain the core idea in your own words without reading the code.
  • Change one input and predict the output before running it.
  • Test one boundary or failure case, then record what you changed.