Node.js · Junior · Question 37 of 75
Can you use await at the top level of a file (outside any function) in Node.js?
- 1Yes, in both CommonJS and ES modules
- ✓Correct answer: Yes, in ES modules
- 3No, never
Explanation
Top-level await is part of ES modules. In CommonJS you must wrap the code in an async function.