JavaScript Promise constructor property is used to return the Promise constructor function for the object. The function which is returned by this property is just a reference to this function, not a Promise containing the function’s name. The JavaScript number constructor, string constructor, and boolean constructor return function Number() { [native code] }, function String() { [native code] }, and function Boolean() { [native code] } respectively.
Syntax:
promise.constructor
Return Value: Promise() { [native code] }
Example 1: This example shows the basic use of Promise constructor property in JavaScript.
Javascript
function gfg(){ Â Â Â Â let prom = new Promise((resolve, reject) => {}) Â Â Â Â let val = prom.constructor; Â Â Â Â console.log(val) } gfg() |
Output:
Ć’ Promise() { [native code] }
Example 2: This example uses the Promise constructor property of JavaScript.
Javascript
function myGeeks() { Â Â Â Â let prom = new Promise((resolve, reject) => { }) Â
    console.log(prom.constructor); } myGeeks() |
[Function: Promise]
Supported Browsers:Â
- Google ChromeÂ
- Edge 12Â
- Mozilla FirefoxÂ
- Opera
- Safari
We have a complete list of Javascript Promise Methods, to check those please go through the Javascript Promise Complete Reference article.