ES6 modules
Information drawn from
Before modules, a variable declared outside any function was a global variable.
With modules, a variable declared outside any function is hidden and not available to other modules unless it is explicitly exported.
Exporting makes a function or object available to other modules. In the next example, I export functions from different modules:
//module "./TodoStore.js"
export default function TodoStore(){}
//module "./UserStore.js"
export default function UserStore(){}
Importing makes a function or object, from other modules, available to the current module.
import TodoStore from "./TodoStore";
import UserStore from "./UserStore";
const todoStore = TodoStore();
const userStore = UserStore();
------------------------------------------------------------------------
Last update on 23 Feb 2020
---