import and export in JavaScript — a practical guide to JavaScript import export with clear examples you can reuse in real projects.
JavaScript Tutorial Series (92/101). Prefer one article? Read the complete JavaScript tutorial.
Short description
Prefer named exports for better refactoring in many codebases.
import/export
// math.js
export const add = (a, b) => a + b;
// main.js
import { add } from './math.js';