wiki/content/20200911154351-promises.md

40 lines
1 KiB
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-30 17:04:36 +00:00
date: 20200911
2024-05-06 20:40:05 +00:00
id: 14e0ce4b-b4b1-46fe-946a-c519550682ac
title: JavaScript Promises
---
# Introduction
A Promise[^1] is an asynchronous action that may complete at some point
and produce a value. It is able to notify anyone who is interested when
its value is available.
``` javascript
let fifteen = Promise.resolve(15);
fifteen.then(value => console.log(`Got ${value}`))
```
# Parallel
- [Executing Promises in Parallel
(Promises.all)](20201111094957-executing_promises_in_parallel_promises_all)
- [Promise.allSettled](20201116163327-promise_allsettled)
# Errors
- [Catching Promise Errors](20201111095100-catching_promise_errors)
- [Finally](20201111095454-javascript_promises_finally)
# Producing & Consuming
Use [Async functions](20201026103714-javascript_async_functions) instead
of this.
- [Producing Promises](20201111095230-producing_promises)
- [Consuming Promises](20201111095316-javascript_consuming_promises)
# Footnotes
[^1]: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise>