Before we talk about the couple of ways of assigning values to variables, let's revisit the data types
by exploring each of these types with code.
So back to Visual Studio code over here.
We are going to start with the primitive data types and it's going to be as this and I want to change
the color to red.
An example of the primitive data type, as we spoke about, is called string.
And this is how it goes to declare a variable with a string value.
It goes like this, like I said, that we are going to stick to const and let without using var.
So for this I will say let full name is equal to John Doe.
And as you can see, the way I'm naming my variables and we have a couple of ways to name variables,
don't worry, we have a section to talk about the best practices or naming conventions.
But for the meantime, just type the way I'm doing it.
But the key note here is that your variable name must not have space in it.
Again, we have a video to talk about the best way to declare variables.
For the meantime, just follow along the way.
As you can see, we have store a value of string inside full name and this is a string simply because
we are using quotes around it and you can use double quotes or single quotes around it and it is the
same.
So if I go ahead and console log the full name, we're going to see John Doe inside the console.
And as you can see, we have John Doe over here.
So this is how a string.
Then the next type of data is called the number.
And we can declare a variable, for example, account number or account balance.
So let me say account balance.
Is equal to, let's say, 200.
So I'm saving a number into a variable.
So if I console log the account balance, we are going to see the 200.
Save it.
And there we go.
We have 200 and I can access the account balance as that and I can also access the full name because
now we have saved these values inside the internal memory of JavaScript.
The next type of data is called Boolean, as we have spoke about, and this one holds only two values,
whether true or false.
So here I can say let is married.
Meaning are you married?
Then it can be false or true.
So if I make it a false meaning, you are not married.
All right.
So if you check inside the console and I set four is married.
As you can see, we have a value of false.
Then the next type of data is called null.
And it goes like this.
Let me add a comment by saying.
Let.
Pending transaction is equal to null.
Save it.
And if you check inside the browser by searching for pending transaction, as you can see, we have
value of Null and the next type is called undefined and I can declare a variable as country and is equal
to undefined.
So what is the differences between undefined and narrow, both null and undefined?
In JavaScript they represent absence of value, but they are used in slightly different circumstances.
For example, for undefined, it is a variable that has been declared, but it has not been assigned
a value and by default it will give you undefined.
And now, on the other hand is an assigned value, meaning it can be assigned to a variable that represents
no value or no object, and it implies an empty or nonexistent value.
So at this point, take it that they are all absence of values when a variable is being declared, but
they have some differences in some situations.
The next type of data type is called the symbol.
So our other comment here by saying symbol and this is a new feature and we are not going to use this
one in this course.
But let me show you.
I will say let unique.
ID equal to symbol, bring the uppercase symbol and then pass in the ID, something like this.
And if you log the unique ID here.
As you can see where I think I need to type it.
Well, let me clear it as unique value or unique ID, And we have this symbol and we are not going to
use this one in this course because it's not commonly used.
Now let's talk about the non primitive types.
So I will go ahead and put it here as non primitive data types.
And one example is the object and object are used to store multiple data about a single entity.
So it goes like this.
Let and I want to provide more data about a user.
And for this one too, we have a section to talk about object functions, strings and others.
But for the meantime, I just want to show you the different types of data types.
And for this it goes like key value pair and if I want to save the first name about a user and I'll
provide as John, it's supposed to be colon but not equal to then comma.
And if I want to save the last name.
And I will say, though, as you can see for this one, we can save multiple data in a single value
or variable.
And I will say 30 if I go ahead and console log the user here.
We have all the properties as they stand right now.
Don't worry about objects If you are new to programming, I just want to show you how it looks like
and the next type of primitive data type is called array.
Again, we have a section to talk about array.
So let me show you an example of code.
And it goes like this.
And for this I want to declare a variable called transactions amount and is equal to array like that
and provide the values here as that so I can save multiple values inside arrays.
So if I search for transactions amount as you can see, these are the values inside them.
And lastly, it's about functions.
Again, don't worry about these ones because these are advanced topics.
I just want to show you the syntax and example of each of the data types.
So here I will say let greet user and as arrow function and inside here I can go ahead and console log.
Good morning.
Great.
Save it.
And inside the console here, if I look for great user and call the function as that I have.
Good morning.
At this point, don't worry about the syntax.
If it looks confusing, we have a specific section to dive in more, but the purpose for this video
to show you examples of each of the primitive data types.
All right.
The next video we will have a look at the best way for naming variables.