Games Node.js Loop Quest Don't block the chef
Cut the work into chunks
A job split into chunks with setImmediate, and one other job waiting its turn.
let i = 0;function work() { console.log('chunk ' + ++i); if (i < 3) setImmediate(work);}setImmediate(() => console.log('other job'));work();1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…