Node.js · Middle · Question 10 of 75
What does await setTimeout(1000) imported from node:timers/promises do?
- ✓Correct answer: Waits about one second without blocking the event loop
- 2Blocks the thread for one second
- 3Throws, because
setTimeoutdoesn't return a promise
Explanation
node:timers/promises has promise versions of setTimeout, setImmediate and setInterval (an async iterator). They also accept an AbortSignal.