CONCEPTS
01Exporting values (named vs default)
02Importing values
03Module scope
04Dynamic imports
05CommonJS vs ES Modules
06Bundlers (Webpack, Vite) overview
SYNTAX_DEMO
Organizing files
// math.js
export const add = (a, b) => a + b;
export default function multiply(a, b) {
return a * b;
}
// app.js
import multiply, { add } from './math.js';
console.log(add(2, 3)); // 5
console.log(multiply(2, 3)); // 6
// Dynamic import
import('./math.js').then(module => console.log(module));