wiki/content/20201111095230-javascript_producing_promises.md

28 lines
522 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-30 17:04:36 +00:00
date: 20201111
2024-05-06 20:40:05 +00:00
id: 1cd276d1-1af0-4472-aec6-bfd148cb5361
title: JavaScript Producing Promises
---
# Advice
Use [Async functions](20201026103714-javascript_async_functions) instead
of this.
# Syntax
``` javascript
const p = new Promise(
function (resolve, reject) { // (A)
if (true /* replace true with your own logic */) {
resolve(value); // success
} else {
reject(reason); // failure
}
});
```
# Related
- [JavaScript Promises](20200911154351-promises)