1
00:00:00,330 --> 00:00:09,210
And once we have executed our first code in code, let's quickly cover the concept of global or global

2
00:00:09,210 --> 00:00:17,660
variables in and the emphasis is on the word quickly, yes, there are more global variables available,

3
00:00:18,000 --> 00:00:22,050
but the idea is not to spend half an hour in Slidell.

4
00:00:22,410 --> 00:00:24,720
Instead, I would want to give you a general idea.

5
00:00:25,230 --> 00:00:29,250
And as we progress with the course, don't worry, we will implement them.

6
00:00:29,760 --> 00:00:35,900
And that way you can right away see them in action, not just some random general description.

7
00:00:36,300 --> 00:00:43,320
And before we continue, let me just mention that throughout the trial, the code from the previous

8
00:00:43,320 --> 00:00:46,630
video, I'm going to say in the file.

9
00:00:46,890 --> 00:00:52,380
So, for example, remember our first complex app with amount and all that.

10
00:00:53,160 --> 00:01:02,030
So what I did, I created a file by the one I often introduce and then I just copy and paste it.

11
00:01:02,040 --> 00:01:06,550
And this is what I'm going to do throughout the note tutorial part of the course.

12
00:01:06,870 --> 00:01:10,110
So that way you can always have access to the code.

13
00:01:10,380 --> 00:01:13,660
And if you ever need to, you can jog your memory.

14
00:01:13,680 --> 00:01:18,840
Now, if you don't want to use my one, if you're adding your own comments and all that, I would also

15
00:01:18,840 --> 00:01:25,140
suggest doing that was essentially just create a file, just dump it, and then that where you are slowly

16
00:01:25,140 --> 00:01:26,150
progressing on the course.

17
00:01:26,370 --> 00:01:31,590
And if you ever need to go back and refresh your memory, you always have that option.

18
00:01:31,860 --> 00:01:39,510
And keep in mind that if you would want to run this file, you simply go with node and then whatever

19
00:01:39,510 --> 00:01:40,020
the file name.

20
00:01:40,020 --> 00:01:40,170
Right.

21
00:01:40,200 --> 00:01:43,880
So in my case, that would be one dash intro.

22
00:01:44,850 --> 00:01:50,220
Again, I'm going to keep on numbering them because I'm just annoying that way part.

23
00:01:50,280 --> 00:01:50,920
You don't have to.

24
00:01:51,160 --> 00:01:52,920
That is really up to you.

25
00:01:53,160 --> 00:01:55,020
So back to the global.

26
00:01:56,260 --> 00:02:03,910
When we work in religious applications, we know a very cool thing is the fact that we have access to

27
00:02:03,910 --> 00:02:10,060
the window object and the reason why it's so cool because in the window object, we can get a bunch

28
00:02:10,060 --> 00:02:12,090
of useful things right.

29
00:02:12,340 --> 00:02:19,000
So, for example, we can get a square selector so I can select the node, I can get built and fetch

30
00:02:19,330 --> 00:02:21,010
and hopefully you get the gist.

31
00:02:21,610 --> 00:02:26,140
Now, I don't want to rain on your parade, but, you know, there's no window.

32
00:02:27,120 --> 00:02:32,790
Why won't because there's no browser, so there's no window object, so if you'll try to access window,

33
00:02:33,150 --> 00:02:37,920
no, we'll spit back the error and most likely your app will crash.

34
00:02:38,700 --> 00:02:40,800
Now, there are some Globalstar.

35
00:02:40,800 --> 00:02:47,220
Of course, there is this concept of global variables and essentially what global variables means that

36
00:02:47,670 --> 00:02:50,140
anywhere in your application you can access them.

37
00:02:50,460 --> 00:02:57,420
So no matter how complex my application gets, how nice that it gets or whatever, I'll always have

38
00:02:57,420 --> 00:02:59,660
access to those variables.

39
00:03:00,000 --> 00:03:03,720
And again, let me repeat, these are just some of the variables.

40
00:03:03,750 --> 00:03:08,330
There's more and I'm not going to spend hours and hours talking about them.

41
00:03:08,580 --> 00:03:11,430
I simply want to give you a general idea.

42
00:03:11,430 --> 00:03:14,910
And then, like I said, we'll start using them and you'll see them in action.

43
00:03:15,120 --> 00:03:24,090
And in my opinion, that's just going to make it way clearer about what in fact they're doing and some

44
00:03:24,090 --> 00:03:25,110
of the useful ones.

45
00:03:25,110 --> 00:03:26,110
We have their name.

46
00:03:26,310 --> 00:03:28,590
So that would be underscore, underscore there.

47
00:03:28,600 --> 00:03:31,920
And I'm just going to give us a path to current directory.

48
00:03:32,250 --> 00:03:37,160
Then we have also underscore underscore filename, which, as you can see, is going to give us a file

49
00:03:37,170 --> 00:03:43,890
name then we have required, which is a function to use modules as well as the module that would be

50
00:03:43,890 --> 00:03:45,630
info about the current module.

51
00:03:45,960 --> 00:03:53,610
Now these two will literally cover them in the upcoming videos because our next big topic is going to

52
00:03:53,610 --> 00:03:54,160
be modules.

53
00:03:54,720 --> 00:04:02,130
So for the time being, just remember that we have require a module and you'll see them in action in

54
00:04:02,140 --> 00:04:02,550
real time.

55
00:04:02,970 --> 00:04:06,540
And then we have a very, very, very useful one.

56
00:04:06,750 --> 00:04:09,000
And that one is a process.

57
00:04:09,300 --> 00:04:17,550
And why it's so useful, because it gives us a info about the environment where the program is executed,

58
00:04:17,850 --> 00:04:21,480
because we need to keep in mind when it comes to a node at.

59
00:04:22,310 --> 00:04:29,630
At the moment, yeah, we're executing that on our machines, but when you deploy, for example, your

60
00:04:29,630 --> 00:04:36,320
API, so for example, your server right where it is sitting, it is sitting on the ocean or Heroku

61
00:04:36,320 --> 00:04:36,880
or whatever.

62
00:04:37,370 --> 00:04:41,380
So that, of course, is already a different environment based on that environment.

63
00:04:41,720 --> 00:04:45,880
You can make a bunch of decisions in your application.

64
00:04:46,340 --> 00:04:53,660
Again, if you'll take a look at the process right now is just going to be a giant object of jibberish

65
00:04:53,660 --> 00:04:53,980
data.

66
00:04:54,170 --> 00:05:00,980
But trust me, as we're progressing, we the course will find a bunch of useful properties that will

67
00:05:00,980 --> 00:05:03,340
implement in our application.

68
00:05:03,740 --> 00:05:10,290
Now, any of them, you can simply control log and you'll get that useful data so you can just run a

69
00:05:10,310 --> 00:05:10,700
log.

70
00:05:10,700 --> 00:05:15,110
And then, for example, there again, I'm not going to console all of them.

71
00:05:15,320 --> 00:05:17,270
Probably the biggest one is going to be the process.

72
00:05:17,280 --> 00:05:24,050
Like I said, you'll get a bunch of properties that at the moment will look like a jibberish and I simply

73
00:05:24,050 --> 00:05:24,830
need to save.

74
00:05:25,010 --> 00:05:28,790
Then we go with node and appoggiaturas.

75
00:05:28,820 --> 00:05:31,960
We run that and this gives me the path.

76
00:05:32,270 --> 00:05:37,210
So if you're interested, you can console the rest of them as well.

77
00:05:37,640 --> 00:05:42,740
But in my case, I'm going to stop with their name now.

78
00:05:42,770 --> 00:05:44,730
Also, very quickly.

79
00:05:44,780 --> 00:05:45,230
Yes.

80
00:05:45,230 --> 00:05:46,840
You have access to the console.

81
00:05:47,330 --> 00:05:50,720
So as you can see, in order to console log, we have to use the console.

82
00:05:50,900 --> 00:05:53,390
So that is also something that is available globally.

83
00:05:53,670 --> 00:06:01,190
Then just like in and even address, we have set interval as well as a set time up.

84
00:06:01,460 --> 00:06:04,730
So you can run these ones and I'm not going to run both of them.

85
00:06:04,730 --> 00:06:10,970
But I'll show you a set interval where very quickly, just so you don't think that I'm cheating and

86
00:06:10,970 --> 00:06:15,650
the way it's going to look like we have our callback function, and then I'll say that my interval is

87
00:06:15,650 --> 00:06:21,020
going to run every second and I must type a world otherwise.

88
00:06:21,300 --> 00:06:23,660
Well, what kind of tutorial is this?

89
00:06:23,990 --> 00:06:29,420
And again, we simply go back to node and then arpeggios.

90
00:06:29,660 --> 00:06:37,070
And as you can see now, after every second I have a world in a console and in order to stop it, remember,

91
00:06:37,070 --> 00:06:39,530
the command was control.

92
00:06:39,560 --> 00:06:43,610
And see before we move on and start talking about the modules.

93
00:06:44,420 --> 00:06:52,660
Let me also mention something else where essentially we don't need to type node and then arpeggios.

94
00:06:52,910 --> 00:06:55,220
You can simply write node.

95
00:06:55,220 --> 00:07:02,410
And then however, throughout the course I'll probably keep on typing just just because I'm annoyed.

96
00:07:02,930 --> 00:07:04,130
That would be the first thing.

97
00:07:04,370 --> 00:07:08,390
But the second thing, and this is not a node thing, this is actually a terminal.

98
00:07:08,900 --> 00:07:12,710
If you don't want to type it, you can simply go back to the previous command.

99
00:07:13,130 --> 00:07:19,730
And not to do that, you need to press on Arrow, key up and check it out the moment you press.

100
00:07:20,330 --> 00:07:23,710
That was my previous command and then I have one before that.

101
00:07:23,960 --> 00:07:32,180
So in my case, that node and then again, you don't need to have that just extension, but probably

102
00:07:32,300 --> 00:07:32,930
I will.

103
00:07:33,350 --> 00:07:37,100
And then you just go back to the previous command and then press.

104
00:07:37,100 --> 00:07:41,510
And again, you just execute that command if you want to clear the console.

105
00:07:41,520 --> 00:07:43,040
Again, this is not a node thing.

106
00:07:43,040 --> 00:07:43,880
This is a terminal.

107
00:07:44,060 --> 00:07:44,960
I just type clear.

108
00:07:45,320 --> 00:07:52,190
And lastly, to answer the question that's probably bugging you the most, we always have to just type

109
00:07:52,190 --> 00:07:57,440
node and then define them, because as we are going to be testing, especially in tutorial, it will

110
00:07:57,440 --> 00:07:58,760
probably get annoying.

111
00:07:59,060 --> 00:08:02,630
And the answer is yes, but only for now.

112
00:08:03,470 --> 00:08:09,560
Once we learn about NPM, the external packages, which at the moment I fully understand doesn't make

113
00:08:09,560 --> 00:08:10,460
any sense at all.

114
00:08:10,910 --> 00:08:16,210
Then there's command that effectively will restart our application.

115
00:08:16,220 --> 00:08:24,080
So we'll have to install some third party module, some external library, and I will do the job of

116
00:08:24,080 --> 00:08:26,110
restarting the application for now.

117
00:08:26,150 --> 00:08:32,390
Yes, all throughout the Turrill up until the point where we cover that external library and external

118
00:08:32,390 --> 00:08:33,580
libraries in general.

119
00:08:33,590 --> 00:08:37,820
Yes, we'll have to type node and then whatever is the fine.

120
00:08:38,330 --> 00:08:41,820
I know it's a little bit annoying, but I just don't want to skip ahead.

121
00:08:42,289 --> 00:08:47,570
I want to get us there with a full information of what is happening.

122
00:08:47,960 --> 00:08:55,670
So with this in place, with clear understanding of the global variables in node.

123
00:08:55,970 --> 00:09:01,400
Now, let's move on to our next topic, which is going to be modules in node.

