Constructs a new promise.
Optional
executor: (The executor function that is called immediately when the promise is constructed. It
is passed two functions, resolve
and reject
, that can be called to resolve or
reject the promise respectively.
Readonly
[toStatic
Readonly
[species]Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
Optional
onfinally: () => voidThe callback to execute when the Promise is settled (fulfilled or rejected).
A Promise for the completion of the callback.
Rejects the promise with the specified reason.
The reason for rejecting the promise.
Static
allCreates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
An array of Promises.
A new Promise.
Static
allCreates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.
An array of Promises.
A new Promise.
Static
delayReturns a promise that is resolved after a specified delay.
The number of milliseconds to delay.
A promise that is resolved after the specified delay.
Static
raceStatic
rejectCreates a new rejected promise for the provided reason.
Optional
reason: anyThe reason the promise was rejected.
A new rejected Promise.
Static
resolveCreates a new resolved promise.
A resolved promise.
The
Promise
class is a subclass of the globalPromise
class that adds the ability to resolve or reject the promise from outside of the executor function.