Types of JScript Variables and Constants

JScript has a number of data types that you may find useful as you write your code. Efficient use of data types allows a program to load and run faster than a program that uses the default JScript data type. In addition, the compiler can provide valuable error messages and warnings about the misuse of the various types.

Discussion

If, for example, a variable will always store an integer whose value will never exceed 1,000,000, it makes no sense to use an 8-byte double type. Instead, the most efficient type for this data is int, which is a 4-byte integer type that stores data values from –2,147,483,648 to 2,147,483,647.

Declaring a variable or constant with type annotation ensures that the variable or constant stores only data of the appropriate type. JScript has a number of other data types for type annotation. For more information, see Data Type Summary. To add types to JScript, either import an assembly that contains types or declare user-defined types (classes).

See Also

Concepts

Declaring JScript Variables and Constants

Other Resources

JScript Variables and Constants

JScript Data Types