I don't know why is promise1
keeps getting called even though I never tried to resolve it.
function successCallback() {
console.log("doSomething func succeeded with sucess");
}
function failureCallback() {
console.log("doSomething func failed with error");
}
let promis1 = new Promise((res, rej) => {
setTimeout(() => {
console.log(`Finally got called`);
return res(successCallback());
}, 5000);
});
function promise2(value) {
return new Promise((res, rej) => {
console.log(`This is getting called for some reason ${value}`)
return res(failureCallback());
});
}
Promise.resolve("6").then(promise2(6));
And here is the output that Im getting:
This is getting called for some reason 6
doSomething func failed with error
Finally got called
doSomething func succeeded with sucess
[Done] exited with code=0 in 5.525 seconds