I have the following code:
new Promise((resolve, reject) => {
resolve(1)
}).then(value => {
return 2
})
I resolve the initial promise with 1
. Then in the then
block I do return 2
. Does this return a promise resolved with the value 2?
Yes. Calling .then
creates a new promise, and that promise will resolve to whatever you return in the callback.