Today I was just exploring Promises in JavaScript and I came across this:
Promise.reject("Failed");
Gives
Promise { <state>: "rejected", <reason>: "Failed" }
Uncaught (in promise) Failed
Whereas,
Promise.reject("Failed").catch((reason) => console.log(reason));
Gives
Failed
Promise { <state>: "fulfilled", <value>: undefined }
I get the part that in the latter, the rejection is caught and hence just a normal console message but why is the promise itself changed to fulfilled when it was rejected.