Data Type Summary
JScript provides many data types to use in your programs. These types can be divided into two main categories, value data types and reference data types (also referred to as JScript objects). To add types to JScript, you can import namespaces or packages that contain new data types, or you can define new classes that can be used as new data types.
Data Type Details
The following table shows the value data types supported by JScript. The second column describes the equivalent Microsoft .NET Framework data type. You can declare a variable of the .NET Framework type or the JScript value type and achieve exactly the same results. The storage size (where applicable) and range are also given for each type. The third column lists the amount of storage required for one instance of a given type, if applicable. The fourth column provides the range of values that can be stored by a given type.
JScript value type |
.NET Framework type |
Storage size |
Range |
---|---|---|---|
N/A |
true or false |
||
2 bytes |
Any Unicode character |
||
float (single-precision floating-point) |
4 bytes |
Approximate range is -3.4E+38 to 3.4E+38 with accuracy of about 7 digits. Can represent numbers as small as 1E-44. |
|
8 bytes |
Approximate range is -1.79E+308 to 1.79E+308 with accuracy of about 15 digits. Can represent numbers as small as 1E-323. |
||
12 bytes (integral part) |
Approximate range is -7.9E+28 to 7.9E+28 with accuracy of 28 digits. Can represent numbers as small as 1E-28. |
||
byte (unsigned) |
1 byte |
0 to 255 |
|
ushort (unsigned short integer) |
2 bytes |
0 to 65,535 |
|
uint (unsigned integer) |
4 bytes |
0 to 4,294,967,295 |
|
ulong (unsigned extended integer) |
8 bytes |
0 to approximately 1.8E+19 |
|
sbyte (signed) |
1 byte |
-128 to 127 |
|
short (signed short integer) |
2 bytes |
-32,768 to 32,767 |
|
int (signed integer) |
4 bytes |
-2,147,483,648 to 2,147,483,647 |
|
long (signed extended integer) |
8 bytes |
Approximately -9.2E+18 to 9.2E+18 |
|
void |
N/A |
N/A |
Used as the return type for a function that does not return a value. |
The next table shows the reference data types (JScript objects) that JScript provides and that can be used as types. Reference types do not have a predefined specific storage size.
JScript reference type |
.NET Framework type |
Refers to |
---|---|---|
No direct equivalent |
An Automation object. |
|
Interoperates with Array and typed arrays |
Arrays of any type. |
|
Interoperates with Boolean |
A Boolean value, either true or false. |
|
Interoperates with DateTime |
Dates are implemented using the JScript Date object. The range is approximately 285,616 years on either side of January 1, 1970. |
|
No direct equivalent |
An enumeration of items in a collection. For backward compatibility only. |
|
No direct equivalent |
An Error object. |
|
No direct equivalent |
A Function object. |
|
Interoperates with Double |
A numeric value with an approximate range of -1.79E+308 to 1.79E+308 and with an accuracy of about 15 digits. Can represent numbers as small as 1E-323. |
|
Interoperates with Object |
An Object reference. |
|
Interoperates with Regex |
A regular expression object. |
|
String Data Type (variable-length) |
0 to approximately 2 billion Unicode characters. Each character is 16 bits (two bytes). |
|
String Object (variable-length) |
Interoperates with String |
0 to approximately 2 billion Unicode characters. Each character is 16 bits (two bytes). |
No direct equivalent |
A read-only Visual Basic array. For backward compatibility only. |
Note
In scientific notation, E refers to a power of 10. Therefore, 3.56E+2 signifies 3.56 x 102 or 356, and 3.56E-2 signifies 3.56 / 102 or 0.0356.
See Also
Concepts
Copying, Passing, and Comparing Data
Reference
Other Resources
Data Types (Visual Studio - JScript)
Objects (Visual Studio - JScript)
Change History
Date |
History |
Reason |
---|---|---|
September 2009 |
Added note about scientific notation. |
Information enhancement. |