Variables : Variables : Language Basics JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Language Basics » Variables »

 

Variables














Variables in JavaScript are defined by using the var operator (short for variable), followed by the variable name, such as:








var test = "hi";



In this example, the variable test is declared and given an initialization value of "hi" (a string).

You can also define two or more variables using the same var statement:








var test = "hi", test2 = "hola";



Variables using the same var statement don't have to be of the same type:








var test = "hi", age = 25;



variables in JavaScript do not require initialization:








var test;







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Language Basics
» Variables