-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst.js
More file actions
56 lines (35 loc) · 1.16 KB
/
first.js
File metadata and controls
56 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//export and import in javascript
// // export an array
let months = ['Jan', 'Feb', 'Mar','Apr', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// // export a constant
// export const MODULES_BECAME_STANDARD_YEAR = 2015;
// // export a class
// export class User {
// constructor(name) {
// this.name = name;
// }
// }
//there are two types of exports named exports and default exports
//named exports for multiple exports
//and default exports for single export so you can avoid using curly braces
/*
Why export default exist ?
5. Why it exists
Because most real-world projects organize code as:
One class per file
One utility function per file
One React component per file
Using export default makes that convention look clean and natural.
1. What export default really means
export default doesn’t mean “you can only export one thing in total.”
It simply means:
“This is the main thing being exported from this module.”
You can still export other things alongside it — they just won’t be the default.
*/
function sayHi(user) {
console.log(`hii ${user}!!`);
}
function sayBye(user){
console.log(`bye bye ${user}!!`)
}
export{months,sayBye,sayHi};