`
function promiseExecutor() {
setTimeout(() => {
console.log("Inside promise executor function");
}, 10000);
}
var promise1 = new Promise(); // calls the Promise() constructor function and create new onject of type "Promise"
var promise1WithExecutor = new Promise(promiseExecutor);
// Resolve the promise
var promise1WithExecutor = new Promise(promiseExecutor);
function promise1Executor(resolve, reject) {
setTimeout(() => {
resolve();
console.log("Inside promise executor function");
}, 2000);
}
// Handle the response of promise using then
promise1WithExecutor.then((someValue) => {
responseValue = someValue;
});
// Reject the promise
var promise2WithExecutor = new Promise(promiseExecutor);
function promise2Executor(resolve, reject) {
setTimeout(() => {
reject();
console.log("Inside promise executor function");
}, 2000);
}
// Handle the response of promise using catch
promise2WithExecutor.catch((someValue) => {
responseValue = someValue;
});