function goodFun(){
console.log('this is good fun');
}
function badFun(){
console.log('this is bad fun');
}
const promise = new Promise(goodFun , badFun);
console.log(promise); // status , pending
promise.then(); // resolved
console.log(promise); // status , still pending !!! how ???
promise.then(); // running same promise twice
Output :
this is good fun
Promise { <pending> }
Promise { <pending> }
Once I have resolved the promise, still it shows that it's pending. and second time, it doesn't print the content of "goodFun" , can someone help me, what am I missing ?
UPDATE : Moreover, output of the first console.log(promise) is AFTER the promise.then() ? that's also confusing ? why does it happen ? It should print console output first and then promise.then() second.