ai js promise return 2026-09-01

By Xah Lee. Date: .
work in progress

ai js promise return 2026-09-01

is it true, in a js promise object, the return value of resolve function or reject function has nothing to do with the promise state

(ai answer)

It depends on x. Calling resolve(x) (and never calling reject) only resolves the promise. That is not always the same as fulfilling it.

If x is not a thenable (not a Promise and not an object with a callable .then):

If x is a thenable / Promise:

resolve(Promise.resolve(1));           // outer fulfills with 1
resolve(Promise.reject("err"));        // outer rejects with "err"
resolve(new Promise(() => {}));        // outer stays pending forever

Rare extra cases where resolve(x) still rejects:

So: reject never being called does not guarantee fulfilled. Only resolve(non-thenable) does. resolve(thenable) follows that thenable.