ES Modules (import/export) — JS Technical Interview Questions & Answers
Splitting code across files with the module system.
ES Modules (import/export)
- ES Modules (import/export) (js) is a JS topic. In plain words you use it for a short ES Modules import/export js example in a script in the browser. Don’t start with a slogan — start with that picture.
- Smallest example: the smallest ES Modules import/export js example you can type. Type it, run it, and say what you see. If you can do that from memory, you know ES Modules (import/export) (js).
- From the example next to this theory: Splitting code across files with the module system.
- Trap: only saying “ES Modules import/export js” with no example. Fix that before you talk about advanced JS.
- Viva: what is ES Modules (import/export) (js)? Then show the smallest ES Modules import/export js example you can type. Then name the trap.
Technical Interview Tip: What is ES Modules (import/export) (js)? Show this: the smallest ES Modules import/export js example you can type. Trap: only saying “ES Modules import/export js” with no example.
Code Examples for ES Modules (import/export)
ES Modules (import/export) — working example
// ES module style (bundlers / type=module):
// import { add } from "./math.js";
// export function add(a, b) { return a + b; }
async function loadUser() {
// Runnable stand-in without network:
const data = JSON.parse('{"name":"Ada"}');
return data.name;
}
loadUser().then(console.log);ES Modules (import/export) — eS modules use import/export; fetch loads network JSON — here we simulate parse for the lab.
How to Explain ES Modules (import/export) to an Interviewer
What is ES Modules (import/export) (js)?
Used for a short ES Modules import/export js example a script in the browser Not just the heading
Give one small example of ES Modules (import/export) (js).
the smallest ES Modules import/export js example you can type Splitting code across files with the module system
What mistake do beginners make with ES Modules (import/export) (js)?
only saying “ES Modules import/export js” with no example Show the fix
Where do you use ES Modules (import/export) (js)?
a script in the browser a short ES Modules import/export js example