Variables in JavaScript

Variables in JavaScript

Well, at times, we might need to store some kind of data in our program. For that, we are going to make use of variables. But wait, what do we mean by data? Well, data is some kind of information (and it can be anything like your name, number, age, etc).

Variables in JavaScript

Variables are nothing but containers that we use to store some data. The data that we are going to store can be anything, like name, email address, mobile number, salary, etc. There is something called a data type, which specifies which type of data it is.

Well, JavaScript is a dynamically typed language, so you do not need to specify the type of a variable when you create it. You just can assign the value to it. (we are going to study the concept of data types soon)

So, let’s come back to variables. As said earlier, variables are containers that can hold some data. So now the question arises how can you create a variable?

It is very easy, as of now, there are three ways to create a variable. We will discuss all of them one by one. We are going to give some names to the variables. For if the variable is going to hold some kind of count, we just name that variable as count, or something similar and understandable (however, it is not compulsory, but always recommended). You will understand things once you have a look at the examples.