|
May 5, 2002 Defining Constant Variables Tips: May 2002
Yehuda Shiran, Ph.D.
|
|
The const declaration is very common in other programming languages. It allows you to declare a variable as non-changing. The values of variables declared as const remain constant throughout the life of the application. The advantage of using the const declaration is in making the variable's maintenance a lot easier. When you debug a program, it's very helpful to know which variables can change and which variables cannot change. The syntax of the const declaration is as follows:
where:
are the names of the constants being declared. They are, of course, required. Also:
are the types of the constants being declared. As mentioned in Page 2, the data types are optional in JScript .NET. Finally:
are the values assigned to the constants. Here are some examples:
To learn more on JScript .NET, go to Column 108, JScript .NET, Part II: Major Features.
People who read this tip also read these tips: Look for similar tips by subject: |