ES modules (import / export) are the standard in browsers and Node. One default export per file is common; named exports scale better.
Browser
<script type="module"> — deferred by default, strict mode, CORS for cross-origin.
Node
package.json "type": "module" or .mjs — covered on Node modules lesson.
Important interview questions and answers
- Q: default vs named export?
A: Import syntax differs; named enables tree-shaking clarity. - Q: Circular imports?
A: Possible but design smell—extract shared module.
Self-check
- How load ESM in HTML?
- Why strict mode in modules?
Tip: Re-run the playground code for modules-esm-preview and tweak one line before the MCQs.
Interview prep
- type=module?
Enables import/export in browser scripts.