Variables are use to store some values for a temporary time period. They are data container which may change its value. Variables are the basic part of any programming language.

In JavaScript we declare variable with a keyword ‘VAR’ :

<em>VAR </em>toast;  //Declaration of variable named toast

toast = 7; // Initialization of variable toast to 7 , now toast stores a number ‘7’ in it



This will alert a number 7.

Lets make a String variable:


Var weby=”I love web toasts”; //we can also declare an initialize a variable together;


Last time we study a bit about data types and here we are implementing that concept, don’t know how? Let me explain it to you:

Var toast=7;


Toast is a variable and its data type is number. Yes every variable have a data type.

Var weby=”I love web toasts”;

Weby is a variable with data type String.

Umm, you seems confuse. Why we should know about data type?

Ok, let dive into it again:

Var a=1+2;


It would alert ‘3’because we are using addition operation above. You can blame me that I am making it complex but believe me its not.

Var a=3,


Var c=a+b;

Alert(c); // its result would be 8


Ok, last try

Var b=9;

Var c=a+b;


Alright, this was a very brief overview of Variables. Play with variables by yourself now and leave me a comment if you have any problem. I will definitely help you. We are also available for coaching on Skype 😉

See you in next healthy toast.