Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,020 --> 00:00:03,000
Let's compare for a second.
2
00:00:03,300 --> 00:00:13,560
Our browser window APIs with our Node Global's in the browser, whether we're using the V8 engine like
3
00:00:13,560 --> 00:00:23,160
Chrome or something different like Firefox or Safari, we tend to deal with different things than note.
4
00:00:24,480 --> 00:00:33,390
So while we have global A., We have a window in the browser and in the browser, we tend to deal with
5
00:00:33,970 --> 00:00:44,670
HTML and browsing documents instead of processes like node script or a node server that are running
6
00:00:44,670 --> 00:00:48,150
on your system and so on the browser.
7
00:00:48,150 --> 00:00:55,500
We have things that help us interact with our browsing history and figure out our location.
8
00:00:55,620 --> 00:01:04,950
The current address or URL our browser is pointed to, and there's this navigator object, which gives
9
00:01:04,950 --> 00:01:09,300
us access to data about the browser that we're currently using.
10
00:01:10,140 --> 00:01:16,620
These things don't make very much sense in note, but on the other hand, we have access to things like
11
00:01:16,890 --> 00:01:19,770
the arguments that were passed into our process.
12
00:01:20,190 --> 00:01:29,100
We have information about modules that we've loaded with code and functions that we want to reuse.
13
00:01:29,670 --> 00:01:38,490
And because our node scripts run on our computer and tend to live in files when we're running node scripts,
14
00:01:38,490 --> 00:01:42,450
we can get the file name of that script.
15
00:01:43,170 --> 00:01:51,690
And there's also underscore underscore dir name for the directory in which your script lives, as we'll
16
00:01:51,690 --> 00:01:53,250
see later in the course.
17
00:01:53,280 --> 00:02:01,110
These things will all be very useful for us when writing node applications, but probably the most important
18
00:02:01,110 --> 00:02:09,720
one is this require function here, which will dive really deeply into because you'll see it in just
19
00:02:09,720 --> 00:02:11,850
about every node program.
20
00:02:12,570 --> 00:02:21,840
But for now, just know that the required function here is built into nodes globals, and it allows
21
00:02:21,840 --> 00:02:31,200
us to import functions and modules, many of which allow us to do things that browsers wouldn't allow
22
00:02:31,200 --> 00:02:43,440
us to do, for example, to read and write files on your system and even to create a server that serves
23
00:02:43,440 --> 00:02:45,810
those files over the internet.
24
00:02:46,440 --> 00:02:53,190
Now this is all really high level, and I promise we'll be digging into all of this in way more detail.
25
00:02:53,370 --> 00:03:01,530
But I just wanted to give you a breakdown of some of the more common globals that node provides for
26
00:03:01,530 --> 00:03:05,190
us and compare them to what we have in the browser.
27
00:03:06,490 --> 00:03:16,960
For a complete list of Global's, we can go to our no documentation here and scroll down to the Globals
28
00:03:16,960 --> 00:03:25,990
page where we can see all of our globals, including the Dern name and file name which we mentioned,
29
00:03:26,470 --> 00:03:36,580
as well as some that we haven't seen before, like the exports and the set timeout function here.
30
00:03:38,120 --> 00:03:41,820
Which you might be familiar with from the browser.
31
00:03:41,840 --> 00:03:50,750
It's the equivalent of the set timeout function that we have on the window object, just like the U
32
00:03:50,810 --> 00:04:00,440
R L down here is the note equivalent of the URL class that we can access in our browser console.
33
00:04:01,010 --> 00:04:12,020
And we can see that this URL class, if we go to the URL section here is browser compatible.
34
00:04:12,680 --> 00:04:18,050
It follows this What WG URL standard?
35
00:04:18,650 --> 00:04:29,930
Where what WG is a community, including Apple and Mozilla, that's responsible for many of the web
36
00:04:29,930 --> 00:04:32,840
standards, including HTML.
37
00:04:33,650 --> 00:04:43,190
And this URL class follows browser conventions to help us work with addresses like Example Dawg.
38
00:04:43,820 --> 00:04:53,360
This is an example of how Node has gotten much, much better in recent versions at bridging the gap
39
00:04:53,690 --> 00:04:55,220
between code.
40
00:04:55,220 --> 00:04:58,820
We write on the browser and code that we write and note.
41
00:04:59,600 --> 00:05:09,810
We can see an example of this in how this was added relatively recently in version version 10.0 in 2018.
42
00:05:10,700 --> 00:05:19,700
Little changes like the addition of the URL class, make our life when going from front end to back
43
00:05:19,700 --> 00:05:25,280
end code, which we'll be talking about next just a little bit easier.
44
00:05:26,180 --> 00:05:26,870
All right.
45
00:05:26,990 --> 00:05:35,390
So now that we have a better understanding of the relationship between JavaScript and Node.js and how
46
00:05:35,390 --> 00:05:43,370
JavaScript in the browser differs from JavaScript in Node, let's take a quick break and I'll see you
47
00:05:43,370 --> 00:05:44,360
in the next video.
5428
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.