ES modules (ESM) are JavaScript's native module system. Each file is a module with its own scope.
// math.js
export function add(a, b) {
return a + b;
}
// app.js
import { add } from "./math.js";
console.log(add(2, 3)); // 5
Use export to expose, import to consume.