Notice that we’ve been using the term, fulfilled instead of resolved, and the reason is that a promise can be resolved to another promise and which point its fate becomes dependent on the other promise. If the other promise gets fulfilled our promise gets fulfilled, if the other promise is rejected, our promise gets rejected.
Both alpha and beta are resolved, but they settle to different fates. Alpha gets fulfilled, Beta gets rejected.
const delayFulfill =
() => new Promise(
res => setTimeout(() => res('fulfilled'), 1000)
);
//p
const delayReject =
() => new Promise(
(_, rej) => setTimeout(() => rej(new Error('rejected')), 1000)
);
//p
const alpha = Promise.resolve(delayFulfill());
//p
const beta = Promise.resolve(delayReject());
//p
alpha
.then(v => console.log(v))
.catch(e => console.log(e.message));
//p
beta
.then(v => console.log(v))
.catch(e => console.log(e.message));