Modules encapsulate code, making it reusable and maintainable. With ES6, JavaScript introduced import and export, allowing modularity and scope isolation.
import
export
// math.js export const add = (a, b) => a + b; // main.js import { add } from "./math.js";