An import statement brings identifiers explicitly exported by another ES6 module into your module. Unexported identifiers stay private, so importing a module does not expose everything defined inside it. section 11.2 section 11.2.1
Choose an import form to match what you need:
- Import named exports directly, or rename one with `as`. section 11.2.1
- Import all named exports under a namespace, then access them through properties. section 11.2.1
- Import a module’s default export; combine it with named imports when needed. section 11.2.1
Listing 11.7. Importing from the Ninja.js module
import { message, sayHiToNinja} from "Ninja.js"; #A
assert(message === "Hello", #B
"We can access the imported variable"); #B
assert(sayHiToNinja() === "Hello Yoshi", #B
"We can say hi to Yoshi from outside the module"); #B
assert(typeof ninja === "undefined", #C
"But we cannot access Yoshi directly"); #C
The example imports `message` and `sayHiToNinja` from `Ninja.js`; it accesses both, but not the unexported `ninja` identifier. section 11.2.1












