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 -1038 to 1038 with accuracy of about 7 digits. Can represent numbers as small as 10-44. |
|
8 bytes |
Approximate range is -10308 to 10308 with accuracy of about 15 digits. Can represent numbers as small as 10-323. |
|
|
12 bytes (integral part) |
Approximate range is -1028 to 1028 with accuracy of 28 digits. Can represent numbers as small as 10-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 1020 |
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 -1019 to 1019 |
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 |
Arrays of any type. |
|
Interoperates with Boolean |
A Boolean value, either true or false. |
|
Interoperates with |
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 -10308 to 10308 and with an accuracy of about 15 digits. Can represent numbers as small as 10-323. |
|
Interoperates with |
An Object reference. |
|
Interoperates with |
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. |
See Also
Reference
import Statementpackage Statement
class Statement
Concepts
User-Defined Data TypesOther Resources
Data Types (JScript)Objects (JScript)
JScript Objects