1
00:00:11,200 --> 00:00:17,240
Hey, everyone, in the previous video, we just wrote a few JavaScript comments and we can see that

2
00:00:17,240 --> 00:00:19,250
they're working on our page.

3
00:00:19,820 --> 00:00:26,960
Actually, if you open any other age to Amelle page here, you can see that we have the alert comments

4
00:00:26,960 --> 00:00:32,150
showing this is because all of them are linked to the same JSC file.

5
00:00:32,480 --> 00:00:38,210
This is a bit annoying, but we are going to fix this in a moment before we do it.

6
00:00:38,450 --> 00:00:42,020
Let's talk a little bit about JavaScript syntax.

7
00:00:42,320 --> 00:00:48,500
So syntax regards to the rules we need to follow when writing in this language.

8
00:00:48,800 --> 00:00:53,060
So the first concept that is important to understand is about statements.

9
00:00:53,450 --> 00:00:58,040
Statements are instructions to be executed by the Web browser.

10
00:00:58,610 --> 00:01:04,880
Every statement should be finished with a semicolon in our JavaScript code is going to be composed of

11
00:01:04,880 --> 00:01:06,590
multiple statements.

12
00:01:06,860 --> 00:01:12,950
And these statements are executed in sequential order from top to bottom.

13
00:01:13,190 --> 00:01:16,790
So to test this out, let's go back to Visual Studio Code.

14
00:01:19,420 --> 00:01:21,740
Let's say he raised the alert for now.

15
00:01:23,240 --> 00:01:26,390
And I'm just going to copy this statement.

16
00:01:26,840 --> 00:01:32,120
So, as you can see, we're writing a statement which is an instruction for the browser.

17
00:01:35,280 --> 00:01:36,960
I can just write a statement.

18
00:01:37,020 --> 00:01:37,650
One.

19
00:01:41,900 --> 00:01:45,730
And right below, it's going to be statement, too.

20
00:01:46,010 --> 00:01:48,770
So we are separating them by Sammy Collins.

21
00:01:48,770 --> 00:01:53,820
So when you end a statement, you indicated we have a semicolon.

22
00:01:54,860 --> 00:01:56,390
We could write it like this.

23
00:01:58,000 --> 00:02:03,250
This is valid, but this is not recommended because your code is going to be very messy.

24
00:02:03,790 --> 00:02:07,300
So normally we use one statement, Pearline.

25
00:02:07,510 --> 00:02:12,520
So let's save this going back to our file and refreshing the page.

26
00:02:12,820 --> 00:02:20,680
We can see at the console that first the browser executed the first statement and then the second statement.

27
00:02:21,010 --> 00:02:25,120
So who's responsible for executing these statements?

28
00:02:25,150 --> 00:02:31,180
Normally, if you've learned other programming languages before, you know that we normally have to

29
00:02:31,210 --> 00:02:33,760
install them before we start using them.

30
00:02:34,090 --> 00:02:40,690
But with JavaScript, we don't need to use it because who's responsible for executing these statements?

31
00:02:40,930 --> 00:02:41,920
Is the browser.

32
00:02:42,160 --> 00:02:46,480
So every Web browser has a JavaScript interpreter.

33
00:02:46,690 --> 00:02:53,560
If you go down here, I just included a table with the interpreter for the most popular browsers.

34
00:02:53,830 --> 00:02:56,350
So Google Chrome uses V8.

35
00:02:56,740 --> 00:03:00,580
These interpreters are also called JavaScript engines.

36
00:03:00,850 --> 00:03:09,250
So inside Google Chrome, there's something called V8 that interprets our JavaScript statements and

37
00:03:09,340 --> 00:03:10,570
executes them.

38
00:03:11,080 --> 00:03:15,130
If you want more information, you can just click on these links.

39
00:03:15,880 --> 00:03:22,200
Now, moving ahead, like every other programming language, we can use comments in JavaScript.

40
00:03:22,570 --> 00:03:26,640
So if we want to write something, maybe so we can remember later.

41
00:03:26,650 --> 00:03:32,860
So going back to Visual Studio Code, if I want to explain something about this code, maybe I want

42
00:03:32,860 --> 00:03:38,650
to remember this, or maybe I just want to leave a message to another programming that is going to work

43
00:03:38,650 --> 00:03:39,160
with me.

44
00:03:39,790 --> 00:03:46,810
I can use these double forward slashes and then the browser is not going to read this.

45
00:03:47,140 --> 00:03:48,820
This is a one line comment.

46
00:03:49,120 --> 00:03:52,120
We can see that the next line is not affected.

47
00:03:52,510 --> 00:03:59,250
If we want to write multiline comments, we can just use forward slash asterisk.

48
00:03:59,560 --> 00:04:02,310
And then and it with asterisk.

49
00:04:02,320 --> 00:04:03,170
Forward slash.

50
00:04:03,460 --> 00:04:06,010
So now everything that we write inside here.

51
00:04:07,490 --> 00:04:09,290
He's going to be a comment.

52
00:04:09,350 --> 00:04:12,200
So this is a comment.

53
00:04:12,500 --> 00:04:12,800
All right.

54
00:04:12,830 --> 00:04:14,050
We can't erase this.

55
00:04:14,060 --> 00:04:19,490
So comments are also useful when we don't want to erase a line of code.

56
00:04:19,910 --> 00:04:22,250
But we wanted to be ignored for now.

57
00:04:22,250 --> 00:04:26,420
So we have this alert that was annoying us a little bit.

58
00:04:27,020 --> 00:04:28,130
So let me write it.

59
00:04:32,150 --> 00:04:37,280
And now let's say I don't want it to run every time, but I want to leave this code here because maybe

60
00:04:37,280 --> 00:04:38,960
I want to use it later.

61
00:04:39,380 --> 00:04:44,930
We could just comment the line and then the browser is going to ignore this line.

62
00:04:45,080 --> 00:04:49,010
It's actually easier to do it using a shortcut.

63
00:04:49,040 --> 00:04:55,400
So the most popular text editors have shortcuts to Torgau comments in Visual Studio Code.

64
00:04:55,760 --> 00:05:01,920
If you select one line or maybe multiple lines, you can use shift art a.

65
00:05:02,420 --> 00:05:06,350
And now we are just commenting more easily.

66
00:05:06,500 --> 00:05:11,710
And if we do it again, shift off a it's going to on comment.

67
00:05:12,590 --> 00:05:19,580
If you're having trouble, if this is not working for you, you can just go to add it and you find the

68
00:05:19,640 --> 00:05:24,860
shortcut for the toggle line comment and Targo Block comment.

69
00:05:25,190 --> 00:05:28,810
So in this case, I just want to comment out this line.

70
00:05:28,820 --> 00:05:30,400
So shift out a.

71
00:05:30,650 --> 00:05:33,110
And now this is not going to be executed.

72
00:05:33,440 --> 00:05:34,520
I can save this.

73
00:05:34,910 --> 00:05:41,600
And going back to the browser, refresh on the page, we can see that the browser is ignoring that comment.

74
00:05:42,530 --> 00:05:49,310
Now, just one last thing we need to pay attention is that Chavez script is a case sensitive language.

75
00:05:49,940 --> 00:05:55,130
So this means that we have this comment which uses the console object.

76
00:05:55,310 --> 00:05:59,140
And the name of the method we are executing here is log.

77
00:05:59,510 --> 00:06:03,080
If we try to write it like this, we have a capital C..

78
00:06:03,410 --> 00:06:11,060
This is going to return an error because JavaScript does not know any object written like this.

79
00:06:11,420 --> 00:06:16,160
The console object is reading with lowercase letters.

80
00:06:16,640 --> 00:06:23,030
So because of this, we should be very careful with the names of objects, properties and methods.

81
00:06:23,300 --> 00:06:27,140
So we don't make mistakes, that we would generate errors in our code.

82
00:06:27,350 --> 00:06:30,710
Sometimes we just create a variable and then we try to use it.

83
00:06:30,980 --> 00:06:34,040
We don't understand why our code is not working.

84
00:06:34,220 --> 00:06:38,930
And then after wasting a lot of time, we just realize that we are not writing it.

85
00:06:38,960 --> 00:06:40,670
We have the correct case.

86
00:06:40,910 --> 00:06:44,570
So have this in mind, JavaScript, this case sensitive.

87
00:06:44,750 --> 00:06:47,750
If you pay attention to this, you won't have any problem.

88
00:06:48,380 --> 00:06:50,000
So that was all for this lesson.

89
00:06:50,120 --> 00:06:51,120
Let's go like this.

90
00:06:51,140 --> 00:06:53,270
Little by little, step by step.

91
00:06:53,600 --> 00:06:57,950
And we're gonna start with a little more complex stuff in the next video.

92
00:06:58,250 --> 00:06:59,000
I'll see you then.
