Do settled promise chain handlers fire in the same turn?

Raul-Sebastian Mihăilă raul.mihaila at
Sat Feb 25 21:01:42 UTC 2017

In your example there are 7 promises.

1) `p`
2) `Promise.resolve(console.log('A'))`
3) the promise returned by the first `then` call
4) `Promise.resolve(console.log('B'))`
5) the promise returned by the second `then` call
6) Promise.resolve(console.log('C'))
7) the promise returned by the third `then` call

They are settled in that order. Their reactions are triggered in different
turns. So, the console.log calls happen in different turns.

Even if there was a single promise with three reactions:

p.then(() => console.log('A'));
p.then(() => console.log('B'));
p.then(() => console.log('C'));

the reactions (the callbacks passed to the `then` method) would still be
triggered in different turns.

As you can see in that link, the reactions are iterated and there's a
different job for each reaction.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list