Importing and Exporting Modules in JavaScript

Importing and Exporting Modules in JavaScript

  • Name Export
export const name = 'value'
  • Name Import
import { name } from '...'

  • Default Export
export default 'value'
  • Default Import
import anyName from '...'

  • Rename Export
export { name as newName }
  • Name Import
import { newName } from '...'

  • List Export and Renaming
export {
    name1,
    name2 as newName2
}
  • List Import and Renaming
import {
    name1 as newName1,
    newName2
} from '...'