[ES6 Feature] First of all default
keyword with export
allows us to set Anonymous Name we want to set when we import
it.
If you export it with
export const Clock
,
then you have to import it strictly(ES6 way - using object destructuring syntax for named exports) with
import { Clock } from './Clock
or also can use import * as Clocks from './Clock'
if you want to import all constants/variables(i.e. all named exports jammed into one object). This will make Clocks
as an object with all exported variables/anything within it.
Like
Clocks = {
Clock : Clock \\ import {Clock} from './Clock',
....
}
Named exports are useful to export several values. During the import, it is mandatory to use the same name of the module as it was defined in source file.
But a default export can be imported with any name for example:
export default k = 12; // in file test.js
import m from './test' // note that we got the freedom to use import m instead of import k, because k was default export
console.log(m); // will log 12