Hey, everyone, in the previous video, we just wrote a few JavaScript comments and we can see that
they're working on our page.
Actually, if you open any other age to Amelle page here, you can see that we have the alert comments
showing this is because all of them are linked to the same JSC file.
This is a bit annoying, but we are going to fix this in a moment before we do it.
Let's talk a little bit about JavaScript syntax.
So syntax regards to the rules we need to follow when writing in this language.
So the first concept that is important to understand is about statements.
Statements are instructions to be executed by the Web browser.
Every statement should be finished with a semicolon in our JavaScript code is going to be composed of
multiple statements.
And these statements are executed in sequential order from top to bottom.
So to test this out, let's go back to Visual Studio Code.
Let's say he raised the alert for now.
And I'm just going to copy this statement.
So, as you can see, we're writing a statement which is an instruction for the browser.
I can just write a statement.
One.
And right below, it's going to be statement, too.
So we are separating them by Sammy Collins.
So when you end a statement, you indicated we have a semicolon.
We could write it like this.
This is valid, but this is not recommended because your code is going to be very messy.
So normally we use one statement, Pearline.
So let's save this going back to our file and refreshing the page.
We can see at the console that first the browser executed the first statement and then the second statement.
So who's responsible for executing these statements?
Normally, if you've learned other programming languages before, you know that we normally have to
install them before we start using them.
But with JavaScript, we don't need to use it because who's responsible for executing these statements?
Is the browser.
So every Web browser has a JavaScript interpreter.
If you go down here, I just included a table with the interpreter for the most popular browsers.
So Google Chrome uses V8.
These interpreters are also called JavaScript engines.
So inside Google Chrome, there's something called V8 that interprets our JavaScript statements and
executes them.
If you want more information, you can just click on these links.
Now, moving ahead, like every other programming language, we can use comments in JavaScript.
So if we want to write something, maybe so we can remember later.
So going back to Visual Studio Code, if I want to explain something about this code, maybe I want
to remember this, or maybe I just want to leave a message to another programming that is going to work
with me.
I can use these double forward slashes and then the browser is not going to read this.
This is a one line comment.
We can see that the next line is not affected.
If we want to write multiline comments, we can just use forward slash asterisk.
And then and it with asterisk.
Forward slash.
So now everything that we write inside here.
He's going to be a comment.
So this is a comment.
All right.
We can't erase this.
So comments are also useful when we don't want to erase a line of code.
But we wanted to be ignored for now.
So we have this alert that was annoying us a little bit.
So let me write it.
And now let's say I don't want it to run every time, but I want to leave this code here because maybe
I want to use it later.
We could just comment the line and then the browser is going to ignore this line.
It's actually easier to do it using a shortcut.
So the most popular text editors have shortcuts to Torgau comments in Visual Studio Code.
If you select one line or maybe multiple lines, you can use shift art a.
And now we are just commenting more easily.
And if we do it again, shift off a it's going to on comment.
If you're having trouble, if this is not working for you, you can just go to add it and you find the
shortcut for the toggle line comment and Targo Block comment.
So in this case, I just want to comment out this line.
So shift out a.
And now this is not going to be executed.
I can save this.
And going back to the browser, refresh on the page, we can see that the browser is ignoring that comment.
Now, just one last thing we need to pay attention is that Chavez script is a case sensitive language.
So this means that we have this comment which uses the console object.
And the name of the method we are executing here is log.
If we try to write it like this, we have a capital C..
This is going to return an error because JavaScript does not know any object written like this.
The console object is reading with lowercase letters.
So because of this, we should be very careful with the names of objects, properties and methods.
So we don't make mistakes, that we would generate errors in our code.
Sometimes we just create a variable and then we try to use it.
We don't understand why our code is not working.
And then after wasting a lot of time, we just realize that we are not writing it.
We have the correct case.
So have this in mind, JavaScript, this case sensitive.
If you pay attention to this, you won't have any problem.
So that was all for this lesson.
Let's go like this.
Little by little, step by step.
And we're gonna start with a little more complex stuff in the next video.
I'll see you then.