8 ms·
> The fact that promises must be resolved in the next tick is baked into the spec From all I know, that statement is false. Promises aren't resolved in the nex
by jkrems 9y ago
> The fact that promises must be resolved in the next tick is baked into the spec
From all I know, that statement is false. Promises aren't resolved in the next tick. They should be resolved as part of the microtask queue which can happen at the end of the tick (recursively).
Promise.resolve()
.then(() => console.log('1'))
.then(() => console.log('2'))
.then(() => console.log('still the same tick!'));
setTimeout(() => console.log('timeout happening in the next tick'), 0);
Result:
1
2
still the same tick!
timeout happening in the next tick