Expose several useful bindings without opening up every top-level variable: a named export makes a module’s selected variables or functions available to importing code. section 11.2.1
Export and import by name:
- Mark declarations with export, or export existing bindings together, such as export { message, sayHiToNinja }. section 11.2.1
- Import selected names with braces; use aliases to expose a binding under another name, or import * as a namespace for all named exports. section 11.2.1
- Only exported bindings are accessible from outside the module; an unexported variable remains private to it. section 11.2.1
Listing 11.5. Exporting from a Ninja.js module
const ninja = "Yoshi"; #A
export const message = "Hello"; #B
#B
export function sayHiToNinja() { #B
return message + " " + ninja; #C
}
A small module exports a message and greeting function while keeping its ninja variable unexported. section 11.2.1

