1
00:00:00,150 --> 00:00:08,550
And before we move on to built in modules as well as third party modules, let me throw you a grade

2
00:00:08,970 --> 00:00:15,270
and I'm going to start by removing this console log in the app, Jayesh Weichsel.

3
00:00:15,600 --> 00:00:20,520
And I'm going to create a new file with the same exact name in mind.

4
00:00:21,180 --> 00:00:27,270
As always, if you would like to call this differently, that's totally your option.

5
00:00:27,600 --> 00:00:30,600
And I'm going to go with mine grenade.

6
00:00:30,930 --> 00:00:35,490
So jazz and I'm just fine will create some basic functionality.

7
00:00:36,000 --> 00:00:40,590
And by the way, let me save up jazz, so let's go with const num.

8
00:00:40,620 --> 00:00:47,170
One is equal to five online const and two is equal to ten.

9
00:00:47,670 --> 00:00:53,040
Of course there has to be a function that has these values as always with every tutorial.

10
00:00:53,340 --> 00:00:56,220
So we'll go with our values just for the sake of it.

11
00:00:56,250 --> 00:01:03,180
I'm just going to go with good old function keyword and the old setup, meaning not the arrow function

12
00:01:03,180 --> 00:01:07,080
syntax and simple here will go with the string.

13
00:01:07,260 --> 00:01:10,020
The sum is Colan.

14
00:01:10,290 --> 00:01:16,050
Let's go for template literal and I'll say Namwon plus number two.

15
00:01:16,470 --> 00:01:26,190
And instead of setting up the exports I'll simply invoke and values and I'll throw you that migranyan

16
00:01:26,490 --> 00:01:27,780
that I was talking about.

17
00:01:27,990 --> 00:01:29,280
Where in the app.

18
00:01:29,280 --> 00:01:30,150
Jayesh.

19
00:01:31,090 --> 00:01:39,250
I'm not going to sign to anything, I'll simply write require and then we'll go with my Internet and

20
00:01:39,280 --> 00:01:45,250
I'll let me comment out of these three cents at the moment, they all just overpopulate the console.

21
00:01:45,550 --> 00:01:49,150
And again, let's run Noad and Abcess.

22
00:01:49,300 --> 00:01:53,410
And once we're on our code, we can clearly see in the console something pretty interesting.

23
00:01:53,410 --> 00:01:57,660
Where we have a log of a sum is 15.

24
00:01:58,300 --> 00:01:59,860
So what's happening over here?

25
00:02:00,430 --> 00:02:07,900
Well, when we are setting up everything, if we have a function inside of the module that we invoke,

26
00:02:08,199 --> 00:02:14,320
yes, that code will run even though we didn't assign it to a variable, as you can see clearly here.

27
00:02:14,650 --> 00:02:17,230
And we didn't invoke that variable.

28
00:02:17,710 --> 00:02:21,100
And before we go any further, let me mention three things.

29
00:02:21,460 --> 00:02:23,400
First, it's not unique.

30
00:02:23,410 --> 00:02:25,630
You can also do that in six modules.

31
00:02:26,080 --> 00:02:30,280
And if you took my vanilla JavaScript course, you know that we use that functionality.

32
00:02:30,460 --> 00:02:31,120
Number two.

33
00:02:31,510 --> 00:02:35,250
Yes, throughout the course here and there, we will use this particular setup.

34
00:02:35,560 --> 00:02:37,840
Now, it's going to be with third party modules.

35
00:02:38,050 --> 00:02:43,090
And of course, once we get there, I will remind you about the set up.

36
00:02:43,270 --> 00:02:44,290
So that's how it works.

37
00:02:44,620 --> 00:02:49,090
And third, I wouldn't suggest losing your sleep over it.

38
00:02:49,840 --> 00:02:55,330
Just please remember that when you import a module, you actually invoke it.

39
00:02:55,330 --> 00:02:57,070
And this is really going into weed.

40
00:02:57,070 --> 00:03:04,600
But the reason why that happens is because this code is not just export it on its own.

41
00:03:05,080 --> 00:03:09,930
When the node exports this, it actually wraps it in the function.

42
00:03:10,210 --> 00:03:17,500
So that's why when you're required, you do invoke the code if you have some kind of function that actually

43
00:03:17,500 --> 00:03:18,700
is executed here.

44
00:03:18,940 --> 00:03:19,960
Keep that in mind.

45
00:03:20,230 --> 00:03:25,060
Not talking about exporting something, talking about executing function here and there.

46
00:03:25,060 --> 00:03:30,460
And of course, in this case, you need to use the imagination that will do something way more useful

47
00:03:30,460 --> 00:03:30,910
than this.

48
00:03:30,910 --> 00:03:31,720
At this point.

49
00:03:31,720 --> 00:03:37,060
You are looking at it, OK, I could have just set up that function in objets, and you're 100 percent

50
00:03:37,060 --> 00:03:37,570
correct.

51
00:03:37,930 --> 00:03:43,540
This is the place where you definitely need to use your imagination, where the functionality will use

52
00:03:43,540 --> 00:03:45,670
it for is going to be way more complex.

53
00:03:46,030 --> 00:03:51,070
But the idea is going to be similar where you just require some kind of module.

54
00:03:51,340 --> 00:03:55,330
And behind the scenes, that module will do a bunch of cool stuff.

