Node.js uses a single-threaded event loop model to handle concurrency via non-blocking I/O.
You're designing an API that downloads a large file, processes it, and returns a summary. Blocking code here will freeze the server.
https://www.youtube.com/watch?v=1_EVy3tls0k
await inside a forEach() loop?async/await work under the hood in the event loop?setImmediate(), setTimeout(), and process.nextTick()?What’s the output of the following?
console.log('start');
setTimeout(() => console.log('setTimeout'), 0);
setImmediate(() => console.log('setImmediate'));
process.nextTick(() => console.log('nextTick'));
Promise.resolve().then(() => console.log('promise'));
console.log('end');
Expected :
start
end
nextTick
promise
setImmediate // or setTimeout
setTimeout // or setImmediate depending on platform