In this lecture we learn about JavaScript variables.
So simply what comes in your mind when we talk about the variable.
So simply variables is the name of a story's location.
That means it is something like a box.
Where do we store the elements.
And the reader to type of variable in the javascript one is local variable and then know these global
variable and we'll see about them in this lecture.
So first of all will this created a variable.
It is via a keyword.
So you have to just make use of this vacuum to create any variable.
After that you give the name of the variable.
So if I just say this create the variable a.
That means that this is the name of the variable and you make use of these single equals sign in order
to assign the value to that festival and give this column or semicolon to in these statements.
So if I just sit into and print the value of A that means it.
So that is still that means it is now is stored in the memory location with the value of will.
So you have created your own variable over here with this var cured giving the name a and assigning
the value of tool to it.
So there is some rule while declaring a job I skipped variables and then all these identifiers and let's
see what are those rules of Christie's name must start with a letter A to Z or capital A to Z or on
this score or the dollar sign that means the name of your variable.
So always start with these A to Z that is your alphabetical in the lower case or in the upper case or
it can also start with the underscore or it can also start with this dollar and it should not start
with something like dot.
So if I just create the variable like dirt and contain variable and let me just assign 89 to this it
is so syntax error because this is not valid to do so you can see the rule over here name must start
either with the letter on this score or the dollar sign.
But if you just make the variable like Let me see the variable let me start with a dollar sign and contains
my variable name and this is valid.
So if I just spin this the container that is the value will be eighty nine over here.
So one rule is to create the variable name from this convention and second one is after the first letter
we can use the digit like this over here which is Value 1 is valid but if you just start the variable
name with the letter are basically the number let me said 9.
They would be the variable name then.
This is not valid.
The names should always start with this convention and after that you can put the digit but it should
not start with the digit.
So next one rule over here is javascript variables are case sensitive.
That means the X which is in lowercase and the X in the uppercase are different variable.
So let's take the example of where if I just say X is 89 and if I just print now that d the capital
X then that means you wrote this.
And if I just say here it is so me either.
That is X is not defined.
That means this is small x is not same as the capital X or the uppercase x.
That means the job is good variables are case sensitive so you must take it up.
These three rule while creating the variables in the javascript in these three rules are known as the
identifiers.
So we have to follow these rule in order to create the variables.
So in these starting I have already said you there is two types of variables in the javascript.
First one is local variable and another one is global variable.
So let's see what are those.
So first of all we will see about the local variable.
So javascript the local variable is declared inside the block or once and that means it is accessible
within that function or block only.
So let's take the example.
So first of all this open my Sublime Text which remove this end as you know the javascript Cordy starts
with this script tag and insert this script tag.
So over here inside this script tag is our javascript call.
So let me just create the fun son with the javascript we haven't started over the function but this
simple code that reappears when users call them.
So basically you just create a function with these funds and keyword and giving the name to this function.
Same is creating the variables.
Well it started off once and in the upcoming lecture.
Just remember here that we make use of this a variable that is let me just create one.
So if we just see over here.
This is your local variable which is one type of variable in the database.
So you have created the variable x inside these funds on ABC.
So if I just go over here and console that is your variable which would be X it will so that X is not
defined because this X is visible or this X is accessible inside this scope only that means inside this
function and outside this function the yuks is invisible.
That means yuks on to be reflected over said these funds on so these is your local variable.
That means this variable is declared inside the block or you can make say a function and this is accessible
within this block only and outside this block it is not accessible.
So this is your local variable which is one type of variable in the javascript.
So if I just create another example for you.
So anything that is inside this script tag is is always good.
And after that if I just say if statement which is the conditionals and we haven't started this yet
but I'll just make a point over here.
So if I just say that would just give the condition and give the block just remember about this block
only here and inside this block.
I'll just create an order variable let me say for these my very evil way and this is also your local
variable.
So if you just get the variable y over here that is outside this scope.
So let me just print this should be consolidated log.
So if this make use of this console load log and the way it will this through use some error because
this variable which is way is accessible inside this scope only that means inside this curly braces
and outside this scope or outside this block.
This way is not visible.
That means you can't simply print why you were here.
It.
So either it will throw it either.
So next variable in the Java script is the global variable and the global variable is accessible from
any funds and unlike here which is the case of a local variable.
This variable way was the sensible inside these funds and only or inside this block mainly but in the
case of a global variable it will be accessible from any way that means it will be accessible from any
funds in a variable are declared variable that is outside the funds and are declared outside any window
object is known as the global variable.
So let's take the example of the global variable.
So let me just remove this one and let me just say dot dot.
Let me set 90s my daughter and now that me the script the funds and a and I get confused with these
funds and so instead of funds and let me just remove this and this give Curly places for you know and
if I just create another Collie braces.
So just remember this is one type of Bunsen or basically scope.
So if you just create this very well which is data outside of this scope that means this variable will
be visible over here too.
So that means you can console and plug your data over here.
And similarly this data will be also visible over here inside this and other block.
That means that this data variable is your global variable so this is really easy to understand.
That means any variable that will be visible or that will be reflected in any scope are basically a
variable which will be accessible from any funds and is the global variable.
And if any variable that is only accessible inside one funds and is a local variable.
So this will be read for this lecture and in this lecture we learn about the variables in JavaScript
what are there types like global and local.
And what are identified.
That means you have to make use of some rule in order to create the very well in javascript.
So this was a sort of lecture on the variables we'll see in the next one.