What is process.nextTick in Node.js and how does it relate to the event loop?
A Node.js-specific microtask that runs before promise callbacks. It has higher priority than Promise.then. Use it carefully; excessive nextTick calls can starve promises and the event loop.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Event Loop Interview Questions in JavaScript
1, 4, 3, 2. Sync code runs first (1, 4). Then all microtasks (3). Then one macrotask (2). This is the fundamental event loop order.
Code before await runs synchronously. await pauses the function and schedules the rest as a microtask. Code after the foo() call runs next (sync). Then the rest of foo runs (microtask). So: 1, 3, 2 for the example above.
Yes. The event loop drains all microtasks before rendering. If microtasks take too long, the paint is delayed. Keep microtasks short to maintain smooth rendering.
Still have questions?
Browse all our FAQs or reach out to our support team
