showing results for - "module system in javascript"
Humphrey
15 Jan 2017
1// Default exports
2
3//Function.js//
4export default () => console.log("Hello");
5export default someValue = 10;
6
7//Main.js//
8import oneFunc from './Function';
9oneFunc(); // Hello
10
11import value from './Function'; 
12console.log(value) // 10
13
14// Named exports
15
16//Function.js//
17export const sum(a,b) => a+b;
18export const sub(a,b) => a-b;
19
20//Main.js//
21import {sum,sub} from './Function';
22console.log(sum(1, 2)); // 3
23console.log(sub(2, 1)); // 1
24