Variables are symbolic names for values coded in your script. You use variables to store and manipulate program data.
NOTE WMLScript 1.1 supports only variables that are declared inside functions or passed as function parameters.
This section describes the following information about variables:
Specifying the variable's name.
Examples of variable declarations are:
var x;
var x, y;
var size = 3;
Use the var keyword to declare a variable. If you declare more than one variable in the same statement, separate the variables by a comma. End the variable declaration with a semi-colon (;).
WMLScript 1.1 requires you to declare variables. You must also declare a variable before you can use it. You do not have to initialize variables; if you do not, they are automatically initialized to contain an empty string ("").
A variable's scope is the segment of the program in which the variable can be referenced. A variable's lifetime is the time between the variable declaration and the end of the function. Lifetime is also known as persistence.
Variable names within a function must be unique. Block statements are not used for scoping.
A variable is accessible only within the function in which it has been declared.
var myAge = 46
var yourAge = 60
var ourAge = myAge + yourAge
You access a variable by calling the variable's name. In the example above, the variable ourAge accesses the variables myAge and yourAge.