Need a formatting module to provide both currency and number formatting? A named export makes each value available under a specific name. Unlike a default export, which an importer can name freely, a named export must be requested by its exported name unless the import renames it. section 20.2 section 21.2
Export two functions
export function currency(num) { // Return a formatted currency string } export function number(num) { // Return a number formatted with commas } Each `export` prefixes a declaration, so the declared function name becomes its exported name. The module can have several named exports, but only one default export. section 20.2
You can also declare values first and list their existing bindings afterward: `export { currency, number }`. To give a binding a different public name, use `export { originalName as exportedName }`. Braces require bindings, not raw values; export statements must be at the module’s top level. section 20.2 section 20.4
import { currency, number } from './utils/format'
function details(product) {
return `
price: ${currency(product.price)}
${number(product.quantityAvailable)} in stock ready to ship.
`
}
The product-details function imports `currency` and `number` by their exported names, then calls each where its formatting is needed. section 21.2
If an exported name conflicts with another import, rename it locally: `import { number as formatter } from './utils/format'`. The export is still named `number`; only this module’s local binding is `formatter`. You can import all named exports with `import * as format`, but ordinarily import only what you use. section 21.2
Quick practice
Create a module with two formatting functions. Export both by name, import just one into another module, then rename that import with `as`. Check that the name inside the export braces matches the declared binding. section 20.2 section 21.2

