Grokking Node.js
Vote

0% completed

​

Event Loop and Concurrency

Run the following script and look at the order of its output:

console.log('Start'); setTimeout(() => { console.log('setTimeout'); }, 0); Promise.resolve().then(() => { console.log('Promise'); }); process.nextTick(() => { console.log('nextTick'); }); console.log('End');
Start End nextTick Promise setTimeout

The timer asked for a delay of 0 milliseconds and was scheduled first, yet it ran last. The callback given to process.nextTick was scheduled after the promise, yet it ran before it. Both results follow from how Node

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content