What is the design philosophy behind Promise.reject(reason) wrapping the reason with a Promise while Promise.resolve() not doing so?
So I was reading the article on MDN about Promises and got stuck here:
Unlike Promise.resolve(), Promise.reject() always wraps reason in a new Promise object, even when reason is already a Promise.
I'm just trying to understand what difference it makes in coding. What would happen if Reject
doesn't wrap the reason
with another Promise just as resolve
does and how exactly this simplifies the usage.
Appreciate some hypothetical examples.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/oQLAEKx
Comments
Post a Comment