The spec says (para 5):
The PendingJob records from a single Job Queue are always initiated in FIFO order. This specification does not define the order in which multiple Job Queues are serviced. An ECMAScript implementation may interweave the FIFO evaluation of the PendingJob records of a Job Queue with the evaluation of the PendingJob records of one or more other Job Queues.
Does this mean I can't count on the callback supplied to .then
being evaluated before a callback supplied to setTimeout
in an otherwise synchronous control flow?
In other words, can I depend on the following printing one two
.
setTimeout(() => console.log('two'));
Promise.resolve().then(() => console.log('one'));