spacer
Yehuda Shiran May 5, 2002
Defining Constant Variables
Tips: May 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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:

  const name1 [: type1] = value1 [, ... [, nameN [: typeN] = valueN]];
where:

  name1, ..., nameN 
are the names of the constants being declared. They are, of course, required. Also:

  type1, ..., typeN 
are the types of the constants being declared. As mentioned in Page 2, the data types are optional in JScript .NET. Finally:

  value1, ..., valueN 
are the values assigned to the constants. Here are some examples:

  const index = 5;
  const president : String = "Abraham Lincoln";
  const factor : int = 35, twoThirds : float = 2./3.;
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:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business