1
00:00:00,390 --> 00:00:05,940
In this video, we are going to learn how to pass arguments to our Node.js functions.

2
00:00:06,480 --> 00:00:08,040
So let's get started.

3
00:00:08,640 --> 00:00:14,080
So in order to do that, I'm going to create a EVE lecture folder and create logger that JS file.

4
00:00:14,100 --> 00:00:21,090
So in this file I'm going to look again, but this time I'm going to lock process that.

5
00:00:21,090 --> 00:00:21,900
Argh!

6
00:00:21,990 --> 00:00:29,510
So this is the predefined property and command that we can get the arguments from the environment.

7
00:00:29,520 --> 00:00:32,520
So let's see how it will be work.

8
00:00:32,530 --> 00:00:34,520
In our Node.js function.

9
00:00:34,530 --> 00:00:38,330
We basically lock the incoming arguments from the process.

10
00:00:38,340 --> 00:00:45,150
In order to do that, please save this file and come to lecture regarding the lecture folder structure

11
00:00:45,150 --> 00:00:51,360
and you can run the node command note, empty character and logs.

12
00:00:51,780 --> 00:00:58,350
If you hit enter, you can see that we have two predefined arguments into our process.

13
00:00:58,620 --> 00:01:03,390
We object, so that means we can get the arguments from the process object.

14
00:01:03,390 --> 00:01:09,540
And in the beginning we have already two arguments defined in our application.

15
00:01:09,540 --> 00:01:15,720
The first one is the Node.js exit and the second one is the file that is running now, which is the

16
00:01:15,750 --> 00:01:17,010
logs.

17
00:01:17,610 --> 00:01:18,150
Okay.

18
00:01:18,180 --> 00:01:25,080
So if we would like to pass more arguments, we can write to command, for example, not logs.

19
00:01:25,440 --> 00:01:31,580
Now put the empty character and give the argument and also put empty character, give another argument.

20
00:01:31,590 --> 00:01:36,170
So I have created two new argument into our node command.

21
00:01:36,180 --> 00:01:44,140
If you hit enter, you can see that this time we have four arguments is located under the process arg

22
00:01:44,160 --> 00:01:50,430
we object so see that we can get arguments and run log logs with the node command.

23
00:01:51,580 --> 00:01:54,370
So if you update the code to get our.

24
00:01:55,610 --> 00:01:56,330
Excuse.

25
00:01:57,760 --> 00:01:58,270
Arguments.

26
00:01:58,270 --> 00:02:04,990
For example, I'm going to set the argument this is the array that we can reach the values.

27
00:02:04,990 --> 00:02:06,790
So that's why I'm going to.

28
00:02:08,000 --> 00:02:09,650
Get the argument too.

29
00:02:09,650 --> 00:02:14,840
And argument three, which is the name and the surname operation.

30
00:02:14,840 --> 00:02:18,650
So if you save this file and run this command again.

31
00:02:20,280 --> 00:02:21,300
It entered.

32
00:02:21,330 --> 00:02:27,300
We can see that we basically get the argument to and argument three.

33
00:02:28,500 --> 00:02:32,220
So if we go further to create a function.

34
00:02:33,160 --> 00:02:35,730
I'm going to create any longer function.

35
00:02:35,740 --> 00:02:38,290
Let me put this in here.

36
00:02:38,320 --> 00:02:38,890
Yes.

37
00:02:40,090 --> 00:02:45,820
As you can see that we have created a local function that is including the name and the surname information.

38
00:02:45,820 --> 00:02:51,840
And we basically lock these name and surname information with a given text message.

39
00:02:51,850 --> 00:02:58,460
So also we have to invoke this function into our JS file.

40
00:02:58,480 --> 00:03:00,770
So here you can find the latest code.

41
00:03:00,790 --> 00:03:08,500
So if you run the same command with these two argument, name and surname, hit enter.

42
00:03:08,620 --> 00:03:15,280
As you can see that we can manage to run local JS with getting the process arguments from the Node.js

43
00:03:15,280 --> 00:03:15,910
function.
