Skip to content

Commit 8704477

Browse files
committed
feat: add tutorial of module
1 parent 2f0413b commit 8704477

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
<!-- <script src="src/fetch.js"></script> -->
2929
<!-- <script src="src/spread.js"></script> -->
3030
<!-- <script src="src/destructor.js"></script> -->
31+
<!-- <script src="src/module.js"></script> -->
3132
</body>
3233
</html>

src/module.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This is export of variable.
2+
export let one = 1;
3+
4+
// This is export of variables.
5+
let two = 2;
6+
let three = 3;
7+
export { two, three }
8+
9+
// This is export of class.
10+
export class SomeClass {
11+
constructor(someProp) {
12+
this.someProp = someProp;
13+
}
14+
}
15+
16+
// This is export of class.
17+
export function someFunc() {
18+
console.log("Some text");
19+
}
20+
21+
// This is export of class or function in the end of file.
22+
// export { SomeClass, someFunc }
23+
// export { SomeClass as MyClass, someFunc as myFunc }
24+
25+
// This is import of class or function in the end of file.
26+
// import { SomeClass, someFunc } from "./file.js"
27+
// import { SomeClass as MyClass, someFunc as myFunc } from "./file.js"
28+
// import * as SomeObjects from "./file.js"
29+
30+
// This is export of default class.
31+
export default class NewClass {
32+
constructor(someProp) {
33+
this.someProp = someProp;
34+
}
35+
}
36+
37+
// This is import of default class.
38+
// import NewClass from "./file.js";

0 commit comments

Comments
 (0)