Standard built-ins
Promise
Represents eventual completion or failure. The executor runs during construction; the resolver functions select the outcome and cannot change it on repeated calls. Promise reactions execute later.
Formal Syntax & Structure
javascript syntaxjavascript
new Promise((resolve, reject) => { /* start work */ })Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| executor | function | Receives resolve and reject functions. |
Return Value
Promise
A newly constructed promise.
Working Example
Example Snippetjavascript
const p = new Promise(resolve => { console.log("executor"); resolve(4); });p.then(n => console.log(n));console.log("after");