8 Javascript Variables – JavaScript for Beginners.

Last updated on July 13th, 2020 at 02:36 pm.

8 JS Variables - JavaScript Tutorial 2018

This video is taken from the full course that will teach you HTML, CSS, Programming concepts and Javascript .

Video Transcript:


So what is a ‘variable’.

So in computer science, a variable is said to be a memory location.

However I do like, I do like this definition from MDN which says that a variable is a symbolic name for your values in your application.

So you can use variables to represent specific values.

So in place where you’d be using those values, you use the variable.

So an example, so let’s say you’re building an application for people in a class.

So you can use a variable for name.

So when you use this variable for name, you can have a first instance of name which can be one of the people in class.

Let’s say someone is called ‘p’.

So in other places, you can, you can also change the variable name to the other people in the class.

So a variable represents your values.

So let’s go, so if I come here, you’ll see all these fields.

All of these are represented by variables.

So when you sign up, or when you sign in, when you sign in to Facebook, your email is stored in a variable.

Someone else’s email is also stored in a variable.

So the variable will change based on the value, based on the email of whoever.

So all these are stored in variables.

So let’s say they want to use this in the application.

Somewhere in the application, they will refer to the variable.

Let’s say where.

So let’s say the variable for this is email.

The variable name for this is ‘email’ and the variable name for this one is ‘password’.

So if you come to login, they will check if the variable is equals to what you have added and the password variable is equals to what you have added.

And if that, if that variable exists in the database and the variable for the password also exists in the, in the database, they will let you in.

And then they will use the variable for your name and the variable for your surname to show you your Facebook profile when you login.

So you’ll see your, your name is somewhere there, and your other profile details.

So all of that is stored in a variable.

So a variable must have an identifier.

So if I was to declare a variable ‘var name’, this is the identifier.

It is what identifies the variable.

If you’re new to programming, this can be somewhat confusing.

But just think of, just think of it as a placeholder that can be changed.

You can name your variables whatever you want.

But there are certain rules.

So a variable identifier can be alphanumeric and it can contain the dollar sign or an underscore.

But it cannot start with a number.

You cannot start a variable name with a number.

But you can mix up things the way you want.

So let’s see some examples of names of variables.

So just note that a variable name can contain both letters and numbers, that’s alphanumeric and then it can have the dollar sign also as part of the identifier name.

And it can have an underscore.

So let’s see some examples of legal variable names.

So here we have a ‘var’.

So this is a declaration of a variable.

You declare with the word ‘var’ and then the name of the variable.

So this is an identifier and we say that it can be alphanumeric.

It can have letters and numbers.

So this one only has letters.

So ‘dalmations’, ‘var dalmatians’ is a legal identifier.

And then, this one has both number and letters.

So this is alphanumeric.

You can name it dalmatians101, you can call yours whatever you want.

Just give it whatever name you want to give it that has a letter and a number.

So this one is also legal.

It can start with an underscore.

It can have an underscore in the middle.

It can have an underscore in the end.

Then it can also have this dollar sign in the beginning or even in the end.

So variable cannot be a number.

So like that, that cannot be a variable identifier.

And it cannot start with a number.

So it cannot start with a number and it cannot be a pure number as the identifier for the variable.

And also note that, variable identifiers since JavaScript is case sensitive, if you give two variable names, the same name but in different cases, one is a capital and the other one in small letters, those will be two different variables.


Let’s continue in the next video and we’ll look at more about variables.

This section is from Learn Javascript from Scratch.

Learn Javascript from Scratch

Comment Here

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!


Discover more from Bizanosa

Subscribe now to keep reading and get access to the full archive.

Continue reading