jskatas.org Continuously Learn JavaScript. Your Way.

Modules: import statement

Use import to import functions that have been exported somewhere else.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

use import to import functions that have been exported (somewhere else)

the import statement

  • is only allowed on the root level
  • import an entire module using import <name> from "<moduleName>"

import members

  • import a single member, using import {<memberName>} from "module"

separate multiple members with a comma

  • deepEqual from the assert module
  • notEqual from the assert module

alias imports

  • using member as alias as memberName
  • rename the default export of a module, using default as alias as memberName