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
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.
In This Section
- Types of JScript Variables and Constants
- Discusses how to choose an appropriate data type for a variable and the benefits of proper variable data type selection.
- Declaring JScript Variables and Constants
- Explains how to declare typed and untyped variables and constants and how to initialize them.
- Scope of Variables and Constants
- Illustrates the difference between global and local scopes in JScript and how the local scope shadows the global scope.
- Undefined Values
- Explains the concept of undefined values, how to determine if a variable or property is undefined, and how to undefine variables and properties.
- JScript Identifiers
- Explains how to create valid names for identifiers in JScript.
- JScript Data Types
- Includes links to topics that explain how to use primitive data types, reference data types, and .NET Framework data types in JScript.
- JScript Assignments and Equality
- Explains how JScript assigns values to variables, array elements, and property elements and explains the equality syntax used by JScript.
- JScript Reference
- Lists elements that comprise JScript Language Reference and links to topics that explain the details behind the proper use of language elements.