Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Javascript Variables

Javascript Variables

Variables are used to store values.Before you use a variable in a JavaScript program, you should declare it. Variables are declared with the var keyword.


var variableName;


var variableName = value;

Example of Variable

var m;
var i = 0, j = 0, k = 0;
var i = 13, j = 2, k = 432.42;

Variable Scope

It is the place where you can defined and use a variable. Variable Scope are of two types Global Variable, Local Variable.

  • Global Variable: global variables are those variables which is defined anywhere in your javascript code and you can use that variable wherever you want.

  • Local Variable: local variables are those variables which is defined within a javascript function and you can use that variable only in that function.You cannot use that variable outside from that function.

Example of Global Variable

var v=24;

Example of Local Variable

function demo()
var v=24;

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH