Named Exports
Named exports let a module export multiple values. Use the export keyword before functions, classes, or variables.
Named exports let a module export multiple values. Use the export keyword before functions, classes, or variables.
// math.js — multiple named exports
export const PI = 3.14159;
export function add(a, b) {
return a + b;
}
export function multiply(a, b) {
return a * b;
}
// Or export all at once at the bottom
const subtract = (a, b) => a - b;
export { subtract };
Named exports are explicit about what a module provides — prefer them over default exports for modules with multiple utilities.
More in JavaScript