JavaScript · Senior · Question 36 of 75
How does top-level await in a module affect the modules that import it?
- ✓Correct answer: Their execution waits until the module with
awaitfinishes initializing - 2It doesn't: importing modules receive a promise instead of the export
- 3Top-level
awaitis forbidden in modules, only allowed in scripts
Explanation
A module with top-level await becomes an async node of the graph, and dependent modules run after it. Handy for loading configuration, but a slow await delays the whole branch of the app.