WEBVTT

00:01.580 --> 00:06.560
When you create the program or application in JavaScript or in other program language, you might be

00:06.560 --> 00:09.250
excited by how they work and give us the results.

00:09.860 --> 00:14.440
But you need to know that our code is not a wizard before we create the programs.

00:14.480 --> 00:20.600
There has been already created also a program by other smart people which can read our codes, translate

00:20.600 --> 00:24.470
them and execute in order to make our codes understandable.

00:24.470 --> 00:28.280
For that program, we need to follow the set of rules, which is called Syntex.

00:29.030 --> 00:34.760
In Computer Science, the syntax of a computer language is the set of rules that defines the combinations

00:34.760 --> 00:39.410
of symbols that are considered to be a correctly structured document in that language.

00:40.010 --> 00:44.450
So the JavaScript syntax is the set of rules, how JavaScript programs are constructed.

00:45.020 --> 00:48.310
We always need to be assured that the grammar of our code is valid.

00:49.580 --> 00:53.540
That's the main work of syntax parser, which is the part of JavaScript engine.

00:53.990 --> 01:00.500
It checks the code character by character and if something is wrong, then it throws an error regarding

01:00.500 --> 01:05.180
syntax parser and JavaScript engine, we will discuss how they work in depth in comic sections.

01:06.330 --> 01:11.850
Let's take a look on that example here we have the variable with name, first name and its value, John.

01:13.010 --> 01:18.890
Maybe you don't know yet what variable is or you may not know from other programming languages, it

01:18.890 --> 01:23.780
doesn't matter for now because I'm just trying to demonstrate how important it is to write syntactically

01:23.780 --> 01:24.470
correct code.

01:25.570 --> 01:32.530
So, as we said, the syntax pasturage the code character by character, when it finds the VR and space,

01:32.830 --> 01:39.000
it understands that this is a variable declaration, that it expects the name of the variable and finds

01:39.010 --> 01:45.070
it, which is first name in this case, that it meets the equals sign and finds out that the variable

01:45.070 --> 01:51.280
has the value, which is, John, after the value, the syntax parser says the semicolon and understands

01:51.280 --> 01:53.330
that this is the end of the statement.

01:54.220 --> 01:58.690
So the code is valid and the syntax parser continues to read the next coming Cote's.

01:59.140 --> 02:04.300
If it meets something like this, it will find that there is no equal sign between name of the variable

02:04.300 --> 02:05.050
and the value.

02:05.050 --> 02:12.460
Smith So syntax parser is expecting here the equals sign, but instead of it, it finds other character

02:12.460 --> 02:16.990
which makes the code invalid and therefore syntax parser throws an error.

02:18.190 --> 02:21.310
All right, let's write the same example in brackets.

02:22.370 --> 02:24.170
Their first name equals the John.

02:25.730 --> 02:27.110
Then last name.

02:28.360 --> 02:28.930
Smith.

02:31.280 --> 02:38.330
Reload the page and you see we have syntax error on the third line in script, I just file, it tells

02:38.330 --> 02:40.490
us that we have unexpected string value.

02:41.630 --> 02:48.590
If we place your equal sign that the code will work all right throughout the course, you will learn

02:48.590 --> 02:53.090
how to write the appellate code that will help you to avoid getting errors and mistakes.

02:53.510 --> 02:59.210
But anyway, errors and bugs are our friends because they are the best teachers to write the code correctly.

02:59.940 --> 03:05.480
OK, in this lecture, we have talked about the syntax and how the syntax parser with the code line

03:05.480 --> 03:07.610
by line and character by character.

03:08.180 --> 03:09.350
See you in the next video.
