1
00:00:02,050 --> 00:00:08,810
Now the last thing we saw on the previous definition slide is that Javascript runs on a host environment,

2
00:00:08,860 --> 00:00:15,850
so that means a Javascript engine can be part or can be executed in different environments.

3
00:00:15,850 --> 00:00:18,600
The most well known environment is the browser,

4
00:00:18,650 --> 00:00:24,400
modern browsers have Javascript engines built in and they're therefore capable of executing Javascript

5
00:00:24,400 --> 00:00:28,180
code but you also can run Javascript in other environments,

6
00:00:28,180 --> 00:00:34,810
for example on the server side, so right on a computer without having a browser in between, so not inside

7
00:00:34,810 --> 00:00:40,430
of a browser but simply execute code like this on your machine.

8
00:00:40,480 --> 00:00:47,140
Now Javascript was invented to run in the browser, to make web sites more dynamic, to be able to change

9
00:00:47,200 --> 00:00:55,630
things on a web site without loading a new page you could say because Javascript is able to closely

10
00:00:55,630 --> 00:00:59,890
work together with the loaded HTML code, with CSS,

11
00:00:59,920 --> 00:01:07,450
you can also use Javascript to send background HTTP requests, so to send some behind the scenes requests

12
00:01:07,450 --> 00:01:14,230
and fetch data without reloading the page and much more and it will do all of that throughout the course.

13
00:01:14,230 --> 00:01:19,310
Now there also are certain things Javascript can't do when it runs in the browser environment though,

14
00:01:19,420 --> 00:01:25,570
for example it can't access your local file system for security reasons because otherwise every web

15
00:01:25,570 --> 00:01:32,590
page you visit would be able to read your file system, maybe delete files on your computer and so on which

16
00:01:32,590 --> 00:01:34,120
would be horrible of course

17
00:01:34,390 --> 00:01:37,570
and in general it is running in a sandbox

18
00:01:37,600 --> 00:01:42,760
you can say, it's not able to interact with your operating system and so on, the browser gives you certain

19
00:01:42,760 --> 00:01:47,210
things you can do in this environment and doesn't allow other things.

20
00:01:47,230 --> 00:01:52,180
Now as I said, the browser is only one environment though, the one for which Javascript was invented

21
00:01:52,360 --> 00:01:55,880
but not the only one we're restricted to right now,

22
00:01:55,960 --> 00:02:04,960
instead the Javascript engine Google developed, v8 is the name of the engine, was extracted by some people

23
00:02:05,830 --> 00:02:11,290
to run Javascript anywhere because the idea was if we have the engine in the browser, why don't

24
00:02:11,290 --> 00:02:18,550
we take it out of the browser and then make it available as a standalone tool which you can use to execute

25
00:02:18,550 --> 00:02:21,400
Javascript anywhere else directly on your machine

26
00:02:21,400 --> 00:02:24,240
and this tool is in the end called Node.js.

27
00:02:24,410 --> 00:02:29,800
Now in this course, I'll have a separate module about Node.js where I show you how that works and

28
00:02:29,800 --> 00:02:35,080
how it uses the same Javascript syntax you learned throughout the course but which new features it

29
00:02:35,080 --> 00:02:40,420
brings to the table. For the majority of course however, we'll focus on the browser side because this is

30
00:02:40,420 --> 00:02:43,900
the side where you absolutely need Javascript

31
00:02:43,960 --> 00:02:48,670
and it's also the site where you're able to see more because you have a web page where things change

32
00:02:48,670 --> 00:02:49,870
and so on.

33
00:02:49,870 --> 00:02:55,030
Now back to Node.js though for a second, Node.js can be executed on any machine and therefore it's

34
00:02:55,090 --> 00:03:00,450
also often used to build web back-ends, to build web servers, server side

35
00:03:00,460 --> 00:03:04,490
Javascript is also something you often hear as a description for that.

36
00:03:04,570 --> 00:03:11,830
Now you might know about server side languages like PHP or also Java and other languages as well,

37
00:03:11,830 --> 00:03:17,450
well Javascript with Node.js can also be used to run it on the back-end of a web page,

38
00:03:17,470 --> 00:03:25,180
so on the server and not on the client in the browser of your users. Now Node.js also has certain things

39
00:03:25,180 --> 00:03:30,520
it can do and can't do, since it runs directly on a machine, in Node.js

40
00:03:30,540 --> 00:03:36,700
you're able to access the local file system, so you are able to write files and so on because unlike browser

41
00:03:36,700 --> 00:03:41,110
side Javascript, Node.js code has to be executed actively by you,

42
00:03:41,140 --> 00:03:44,280
it's not like you visit a web page and then this starts happening,

43
00:03:44,320 --> 00:03:47,890
instead it can only access the file system on the machine where it executes

44
00:03:47,890 --> 00:03:53,920
which for example is the server where it runs, not your machine and it's also able to interact with the

45
00:03:53,920 --> 00:03:55,390
operating system and so on.

46
00:03:55,390 --> 00:04:00,430
However on the other hand since it doesn't have direct access to the loaded web page, it can't manipulate

47
00:04:00,490 --> 00:04:02,970
HTML or CSS like browser side.

48
00:04:02,980 --> 00:04:10,530
Javascript is able to do, so we basically have even inverse access capabilities here and these are the

49
00:04:10,530 --> 00:04:13,080
different environments where Javascript is able to run.

50
00:04:13,090 --> 00:04:18,400
Now in this course, we'll focus on the browser side because the Javascript syntax you learned will be the

51
00:04:18,400 --> 00:04:22,030
same, no matter in which environment you run Javascript code

52
00:04:22,360 --> 00:04:27,540
but in the browser, we simply have more visual feedback and can see what happens.

53
00:04:27,670 --> 00:04:32,810
Nonetheless as I said, we have the separate Node.js module later in the course

54
00:04:32,830 --> 00:04:38,620
where I'll also dive into the different things we can do in Node.js and how that works.
