1
00:00:00,750 --> 00:00:03,370
In this section I’ll cover the basics of

2
00:00:03,370 --> 00:00:06,109
JavaScript and Node.js.

3
00:00:06,109 --> 00:00:13,540
Node.js is a runtime environment for running server-side JavaScript and we’ll be using

4
00:00:13,540 --> 00:00:21,610
node.js throughout this course for all the demos and exercises.

5
00:00:21,610 --> 00:00:29,190
If you are well versed with node.js, feel free to skip this section of videos, although going

6
00:00:29,190 --> 00:00:31,770
through them won’t hurt.

7
00:00:31,770 --> 00:00:35,470
So, let’s get started.

8
00:00:35,470 --> 00:00:41,670
First, I hope you have node.js installed on your computer.

9
00:00:41,670 --> 00:00:48,149
If not, please go back to the Environment Setup video from the very first section of

10
00:00:48,149 --> 00:00:50,829
this course.

11
00:00:50,829 --> 00:00:55,190
It explains how to install node.js on your computer.

12
00:00:55,190 --> 00:00:59,990
You’ll also need a suitable text editor or IDE.

13
00:00:59,990 --> 00:01:07,920
I’ll be using VS Code for all the demos in this course and you can use any text editor

14
00:01:07,920 --> 00:01:11,520
or IDE of your choice.

15
00:01:11,520 --> 00:01:14,780
Once you are ready, let’s continue further.

16
00:01:18,920 --> 00:01:21,380
I have created a new folder on my computer

17
00:01:21,380 --> 00:01:27,420
called node-training to store all our node training projects.

18
00:01:27,420 --> 00:01:34,610
Let’s create another folder within this folder called hello world, hello hiphen world.

19
00:01:34,610 --> 00:01:39,560
This folder would serve as our first project.

20
00:01:39,560 --> 00:01:44,409
Right click and open this folder with VS Code.

21
00:01:44,409 --> 00:01:51,270
If you are using any other IDE, you could simply create a new file called app.js in

22
00:01:51,270 --> 00:01:54,090
this folder and open it for editing.

23
00:01:54,090 --> 00:02:06,939
So, I am going to create a new file in our hello-world folder and name it as app.js

24
00:02:06,939 --> 00:02:14,290
In the file, let’s type in console.log, open parenthesis and quotes, and type in Hello

25
00:02:14,290 --> 00:02:18,250
World and end with a semi-colon.

26
00:02:18,250 --> 00:02:20,730
Save the file.

27
00:02:20,730 --> 00:02:27,750
Open the terminal or command prompt, and be sure you are in our project’s folder i.e. hello

28
00:02:27,750 --> 00:02:37,700
world folder and run node space app.js i.e. node space the name of our main file.

29
00:02:37,700 --> 00:02:43,090
You can skip the dot js part and simply run node space app and hit enter

30
00:02:43,090 --> 00:02:49,090
And you should see Hello World printed in the output.

31
00:02:49,090 --> 00:02:51,590
That was pretty easy, right?

32
00:02:51,590 --> 00:03:00,519
As we move ahead in the course, the complexity would of course increase, though, I will do my best

33
00:03:00,519 --> 00:03:06,220
to make even the complex stuff as easy as possible for you.

34
00:03:06,220 --> 00:03:09,340
So, let’s keep going.

35
00:03:11,720 --> 00:03:19,780
As I mentioned earlier, Node.js is a runtime environment for running JavaScript on the

36
00:03:19,780 --> 00:03:21,260
server side.

37
00:03:21,260 --> 00:03:29,819
Until before Node.js was introduced, JavaScript was only used on the client side for client-side scripting, meaning

38
00:03:29,819 --> 00:03:33,489
it could run only in the web browser.

39
00:03:33,489 --> 00:03:38,379
Different browsers use different engines to run JavaScript.

40
00:03:38,379 --> 00:03:47,090
For example, Microsoft Edge uses Chakra, Mozilla Firefox uses SpiderMonkey, and Google Chrome

41
00:03:47,090 --> 00:03:49,450
uses V8.

42
00:03:49,450 --> 00:03:58,349
Node.JS simply uses Google Chrome’s implementation of JavaScript engine i.e.

43
00:03:58,349 --> 00:03:59,400
the V8 engine.

44
00:03:59,400 --> 00:04:08,730
And Node, of course has adapted the V8 engine to suit server-side processing.

45
00:04:08,730 --> 00:04:16,220
So, some browser-specific functionality like window or the document object is not available

46
00:04:16,220 --> 00:04:23,630
in Node and similarly not all Node.js functionality would be available on the on client-side in the browser

47
00:04:23,630 --> 00:04:26,510
for obvious reasons of course.

48
00:04:26,510 --> 00:04:34,910
To be able to work with node, we don’t really need to go in detail as to how node works.

49
00:04:34,910 --> 00:04:43,830
As long as you can write JavaScript, it should be easy to write your code to run on Node.

50
00:04:43,830 --> 00:04:46,930
And we’ll cover the basic JavaScript constructs as well.

51
00:04:46,930 --> 00:04:51,370
So, you don’t have to worry about not knowing JavaScript.

52
00:04:51,370 --> 00:04:54,900
So, let’s keep at it.

53
00:04:57,780 --> 00:05:01,380
To practice Node.js, you don’t need to rely on a

54
00:05:01,380 --> 00:05:03,540
text editor or an IDE.

55
00:05:03,540 --> 00:05:07,130
You can even run it with a command prompt or terminal.

56
00:05:07,130 --> 00:05:10,000
Let me show you what I mean.

57
00:05:10,000 --> 00:05:18,040
Open up the command prompt or terminal, or you can even open PowerShell if you like and type in node

58
00:05:18,040 --> 00:05:26,140
and hit enter. This would take you to node’s shell.

59
00:05:26,150 --> 00:05:33,699
You can write just about any JavaScript here, just like we did in the VS Code editor and test it.

60
00:05:33,699 --> 00:05:38,210
So, let’s try hello world again.

61
00:05:38,210 --> 00:05:51,919
Console dot log, parenthesis, quotes, hello world, semi-colon at the end and hit enter.

62
00:05:51,919 --> 00:05:55,430
And you get the same output as we got in the VS Code.

63
00:05:55,430 --> 00:06:01,150
This could be handy if you have to quickly test out your script without having to create

64
00:06:01,150 --> 00:06:04,740
a new JavaScript file or a new project.

