Importing named members from another module
suggest changeGiven that the module from the Defining a Module section exists in the file test.js, you can import from that module and use its exported members:
import {doSomething, MyClass, PI} from './test'
doSomething()
const mine = new MyClass()
mine.test()
console.log(PI)
somethingPrivate was not exported from test. Importing a name that was not exported is a syntax error, so the call below never runs:
import {somethingPrivate} from './test'
somethingPrivate()
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents