JScript Variables and Constants
In any programming language, data represents information. For example, this string literal contains a question:
'How old am I?'
Variables and constants store data that scripts can easily reference by using the name of the variable or constant. Data stored by a variable may change as a program runs, while data stored by a constant cannot change. A script that uses a variable actually accesses the data that the variable represents. Here is an example in which the variable named NumberOfDaysLeft is assigned the value derived from the difference between EndDate and TodaysDate.
NumberOfDaysLeft = EndDate – TodaysDate;
In a mechanical sense, a script uses variables to store, retrieve, and manipulate the values that appear in scripts. Constants reference data that that does not change. Always create a meaningful variable name to help you remember the variable's purpose and to help others determine the script's functionality.