1
00:00:00,330 --> 00:00:05,160
In this video, we are going to learn how to run Node.js functions.

2
00:00:05,610 --> 00:00:12,120
So in the previous video we are running the console.log operation and we can run the node command with

3
00:00:12,120 --> 00:00:14,160
passing this index file.

4
00:00:14,610 --> 00:00:21,900
So in this video, we are going to create methods and see how these methods in our Node.js applications.

5
00:00:22,200 --> 00:00:25,440
In order to do that, let me create a function in here.

6
00:00:28,210 --> 00:00:29,740
It will be the local function.

7
00:00:32,440 --> 00:00:37,600
And we don't have any parameter and we are using the anonymous function structure.

8
00:00:37,690 --> 00:00:43,750
So basically I'm going to console.log inside of this logger method.

9
00:00:44,650 --> 00:00:48,230
So now as you can see that we have two times log operation.

10
00:00:48,250 --> 00:00:54,550
This is the first line of our indexes and we have a method and inside of the method we have another

11
00:00:54,550 --> 00:00:55,360
log operation.

12
00:00:55,360 --> 00:00:59,080
So that means we have added the other logger function.

13
00:00:59,080 --> 00:01:01,710
Now we can run the node command again.

14
00:01:01,720 --> 00:01:11,500
So in order to do that, please open a terminal, go to section 18, go to lecture folder.

15
00:01:11,530 --> 00:01:15,280
And now I'm going to run, not index.

16
00:01:15,520 --> 00:01:22,580
So that means we are in this folder and we are running node index command to run this index file which

17
00:01:22,780 --> 00:01:24,460
just hit enter.

18
00:01:24,580 --> 00:01:29,420
And as you can see, that response only comes with the first line of code.

19
00:01:29,440 --> 00:01:33,520
So that means the only one time our log operation works.

20
00:01:33,520 --> 00:01:37,630
Why logger function not execute and not write this log?

21
00:01:37,660 --> 00:01:39,880
Because we didn't call it.

22
00:01:40,120 --> 00:01:50,020
So in order to call this function, we need to come here and we basically write the method information

23
00:01:50,020 --> 00:01:51,400
with passing the parameters.

24
00:01:51,400 --> 00:01:55,470
In our case, we don't have any parameter, but we should provide these brackets.

25
00:01:55,480 --> 00:02:02,100
So with this line of code, we basically invoke this method to run the additional look.

26
00:02:02,110 --> 00:02:07,060
So after save this index file, we can run, not index again.

27
00:02:07,060 --> 00:02:08,620
And if you hit enter.

28
00:02:09,930 --> 00:02:16,920
This time you can see that we can execute logger function with invoking into index this file and we

29
00:02:16,920 --> 00:02:22,710
also see the second look which comes from the local function because this time we have invoked the local

30
00:02:22,710 --> 00:02:29,700
function in our index file because note command only runs if there is a calling code into JS file.

31
00:02:30,000 --> 00:02:32,760
So let's develop a little bit more.

32
00:02:32,760 --> 00:02:38,580
So I'm going to write some additional code, which is the anonymous function.

33
00:02:38,910 --> 00:02:42,300
Let me copy paste and I will explain after that.

34
00:02:42,300 --> 00:02:49,770
So instead of creating any method and calling this method, we can directly write method and invoke

35
00:02:49,770 --> 00:02:53,760
method instantly with this format, which is the anonymous function.

36
00:02:53,760 --> 00:02:58,950
So we can use anonymous function in order to imitate execute our index file.

37
00:02:58,980 --> 00:03:07,380
So if we run not index again, we can see that we have three times log operation and these enormous

38
00:03:07,380 --> 00:03:12,720
function instantly execute inside of the log operation or method body.

39
00:03:12,930 --> 00:03:19,320
So as you can see that we have successfully run Node.js function and understand the node commands.
