LoginSignup
0
0

More than 3 years have passed since last update.

ES6 moduleのexportとimportについて

Posted at

本日のゴール

  • export / import について理解を深める

アジェンダ

  • export について
  • import について

1. export について

変数、関数、クラスの宣言文の先頭に export を付けると、その名前で外部ファイルにエクスポートすることができる

export const foo = foo => {
  console.log()
}

export default class bar {
  constructor() {}
  init() {}
}

2. import について

外部モジュールや他のスクリプトなどからエクスポートされた関数、オブジェクト、プリミティブをインポートするために使用

import foo from './foo'
import {foo, bar} from './foo'

参考

MDN - export
MDN - import

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0