The Promise Object: A Placeholder for Future Values

A Promise is an IOU for a value from an async operation, like a network request. It's a placeholder that will eventually hold a result or an error. Use it for fetching data or reading files. The footgun: always add a `.catch()` to handle failures.
A Promise is a placeholder for a value that isn't ready yet. Think of it as an IOU from an asynchronous operation, like a network request, which will eventually be redeemed for a success value or a failure reason. It's the foundation for modern async JavaScript, used everywhere from `fetch()` to database queries. A common mistake is forgetting the rejection case; an unhandled rejection can crash an app, so always chain a `.catch()` or use a `try/catch` with `async/await`.
Read the original → developer.mozilla.org
- #javascript
- #asynchronous
- #web-api
- #promise
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.