Dec 06 2018 4 mins
The [`Promise` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) is used to create a new `Promise` object. It receives a single function as a parameter (known as the _executor function_), which in turn receives the `resolve` and `reject` functions as parameters:
```js
const promise = new Promise((resolve, reject) => {
// Perform some operation, then call either resolve() or reject()
});
```
Within the body of the executor function, you can perform any operation — typically, an asynchronous one. You then either call `resolve(value)` or `reject(reason)`, depending on the outcome of that operation, to fulfill or reject the promise.
Note that the `Promise` object is rejected if an error is thrown within the body of the executor function. The return value of the executor function is ignored.
```js
const promise = new Promise((resolve, reject) => {
// Perform some operation, then call either resolve() or reject()
});
```
Within the body of the executor function, you can perform any operation — typically, an asynchronous one. You then either call `resolve(value)` or `reject(reason)`, depending on the outcome of that operation, to fulfill or reject the promise.
Note that the `Promise` object is rejected if an error is thrown within the body of the executor function. The return value of the executor function is ignored.