Node.js · Junior · Question 19 of 75
What does import() (with parentheses) do?
- 1Imports only types for TypeScript
- ✓Correct answer: Loads a module dynamically at runtime and returns a promise of its namespace
- 3Imports a module synchronously, like
require()
Explanation
Dynamic import() works in both CommonJS and ESM. It is useful for loading code on demand or importing an ES module from CommonJS.