WEBVTT

00:01.530 --> 00:06.810
As we said previously, JavaScript is an object based programming language, and therefore in JavaScript,

00:06.810 --> 00:08.550
almost everything is an object.

00:08.970 --> 00:14.160
Object is a little bit complex data type, and we want to refer to it yet because the whole section

00:14.160 --> 00:15.930
is waiting for you regarding objects.

00:16.680 --> 00:19.330
So we have just said that almost everything is an object.

00:19.350 --> 00:24.690
It means that there is something that is not an object in JavaScript and those are primitives.

00:25.660 --> 00:36.430
JavaScript provides five types of primitive data string, no boolean undefined and no all right strengths

00:36.430 --> 00:39.140
are used for storing and manipulating text.

00:39.520 --> 00:44.290
Let's create variable and assign to its value as John.

00:45.240 --> 00:46.410
Is an instructor.

00:48.840 --> 00:55.350
You tell JavaScript that text is to be treated as text and not as code, simply by enclosing it with

00:55.350 --> 00:58.290
the single quotes, let's log it in council.

00:59.790 --> 01:01.110
I'd consider it like string.

01:03.520 --> 01:09.490
So here we have our string, John is an instructor, instead of single quotes, we can use double quotes.

01:12.110 --> 01:14.400
You see that we have the same results.

01:15.050 --> 01:18.170
They work in the same way, but there is one important issue to note.

01:18.470 --> 01:20.850
The number of calls must always to be matched.

01:21.320 --> 01:26.210
It means that if something starts with double quotes, then must be and with double quotes as well.

01:26.750 --> 01:28.390
And the same for single quotes.

01:28.400 --> 01:31.400
If not, then the string value would be invalid.

01:32.370 --> 01:36.240
So you see that we got syntax error, which tells us that the value is invalid.

01:37.380 --> 01:43.260
And the last thing that I want to show you regarding strength is that if we want to surround one of

01:43.260 --> 01:48.480
the words by quotes, for example, instructor, we have to protect the following group.

01:48.750 --> 01:55.170
If the itself is surrounded by the double quotes, then we have to use single quotes with instructor.

01:57.220 --> 01:59.800
So you see that instructor is in quotes.

02:01.140 --> 02:08.520
OK, now let's see what happens if we don't protect this rule right here, double quotes reload and

02:08.520 --> 02:10.740
we have, again, an error.

02:12.070 --> 02:18.400
All right, let's see what has happened here, JavaScript engine rates, the code from left to right.

02:19.240 --> 02:22.770
It has found the beginning of the string value with double quotes.

02:23.260 --> 02:30.010
So also expect to see adding double quotes and when it finds that counts, that this piece of code is

02:30.010 --> 02:30.430
correct.

02:31.000 --> 02:33.400
But what it sees next is invalid.

02:33.790 --> 02:35.230
Therefore, we get an error.

02:36.880 --> 02:37.360
All right.

02:37.780 --> 02:39.220
Let's move on to the numbers.

02:39.700 --> 02:41.820
JavaScript has only one type of number.

02:42.310 --> 02:46.810
Unlike like many other programming languages, JavaScript doesn't define different types of numbers,

02:46.810 --> 02:54.360
like integers, short, long, floating port and etc. Numbers can be written with or without decimals.

02:54.670 --> 03:04.600
So let's create variable and call it number equals to twenty seven, then luggage in council.

03:08.800 --> 03:15.230
So we have here 27 and also you notice that the color is different from strong values.

03:15.250 --> 03:16.190
It's kind of blue.

03:16.720 --> 03:18.940
We can write numbers with decimals, as we said.

03:19.420 --> 03:19.690
Right.

03:19.720 --> 03:21.790
For example, point twenty three.

03:24.720 --> 03:30.240
One thing to note regarding numbers is that if we write it within quotes, then the JavaScript engine

03:30.240 --> 03:33.870
will understand that the type of value is stirring and not the number.

03:34.290 --> 03:37.710
And it's actually the important thing because it may cause unexpected results.

03:37.710 --> 03:39.110
And you will see that later.

03:39.840 --> 03:43.150
You said that in console, nothing is changed till we have the same number.

03:43.500 --> 03:46.200
The only thing that was changed is the color of the output.

03:46.590 --> 03:51.270
As we said, numbers are always shown in blue and the color of the string is great.

03:52.550 --> 03:58.910
All right, the next primitive data type is Bulleit, which has two possible values, true or false?

03:59.120 --> 04:02.680
The idea of true and false is fundamental in computer programming.

04:03.140 --> 04:07.970
The purpose of pulling data and javascript is just the same as in the world outside programming.

04:08.300 --> 04:14.420
It enables you to answer questions and make decisions based on the answer, mostly boolean data types

04:14.420 --> 04:16.040
that are used in conditional statements.

04:16.520 --> 04:20.480
And just for demonstration purposes, I would like to show you this example.

04:20.960 --> 04:22.610
Create variables, number one.

04:24.080 --> 04:24.960
Equals to five.

04:24.980 --> 04:27.660
And number two equals the ten.

04:28.580 --> 04:33.950
Let's compare these numbers and counsel writes, No one is less than number two.

04:35.770 --> 04:40.930
And he said that we have true because the statement is actually true, five is less than 10.

04:41.320 --> 04:45.550
If we were right, the opposite number one is greater than number two.

04:47.730 --> 04:51.300
Then the result will be false, and I'm sure you understand why.

04:51.870 --> 04:55.350
All right, let's move on to the new variable and.

04:56.560 --> 04:58.900
Then luggage in council.

05:01.600 --> 05:08.950
And see what happens, you see that we have undefined now let's remove this line of code and reload

05:08.950 --> 05:09.690
the page again.

05:10.360 --> 05:14.620
You see that we got an error which tells us that A is not defined.

05:15.200 --> 05:18.820
So what is the difference between undefined and is not defined?

05:19.270 --> 05:26.200
In first case, when we got undefined means that Variable A is created and JavaScript engine has reserved

05:26.200 --> 05:27.310
the memory space for it.

05:27.880 --> 05:34.060
But because of that, the variable is not assigned by the value JavaScript engine automatically assigns

05:34.060 --> 05:40.060
to it undefined, which is the special value, and also it belongs to primitive data type.

05:41.000 --> 05:45.620
So, again, if the variable is declared and is not assigned by the value, it's undefined.

05:46.920 --> 05:52.980
The second case in which we have got a is not defined means that variable itself doesn't exist.

05:53.580 --> 05:57.810
In other words, JavaScript engine could not find the variable in its memory.

05:59.420 --> 06:06.560
All right, let's talk about now, as we saw in previous example, undefined means a variable that has

06:06.560 --> 06:12.770
been declared but has not yet been assigned a value now is an assignment value.

06:13.770 --> 06:16.200
The right for A equals to null.

06:17.220 --> 06:24.030
It can be assigned to the variable as a representation of no value, so the variable whose value is

06:24.030 --> 06:31.530
undefined has never been initialized and the variable whose value is now was explicitly given a value

06:31.530 --> 06:37.050
of null, which means that the variable was explicitly set to have no value.

06:38.020 --> 06:44.280
In other words, NUL is nothing, and it's supposed to be something that doesn't exist.

06:46.030 --> 06:51.130
So, again, Undefined is automatically assigned by JavaScript engine one, the variable does not have

06:51.130 --> 06:57.790
value and we assign now to the variable in order to represent that this variable doesn't have the value.

06:59.230 --> 06:59.910
Makes sense.

07:01.390 --> 07:07.830
OK, it may be a little bit strange and confusing, but I think I made it clear for you.

07:08.320 --> 07:11.710
All right, in this lecture we have discussed briefly primitive data types.

07:12.220 --> 07:13.530
See you in the next video.

07:13.570 --> 07:14.320
Let's go ahead.
