Microsoft® JScript™ JScript Data Types 
JScript Tutorial Previous  Next

Microsoft JScript has six types of data. The main types are numbers, strings, objects, and Booleans. The other two are null and undefined
Strings are delineated by single or double quotation marks. (Use single quotes to type strings that contain quotation marks.) A string is also an object in JScript, but it is a special case, with special properties,. The following are examples of strings:
A string can contain zero or more unicode characters. When it contains zero, it is called a zerolength string ("")."The cow jumped over the moon." '"Avast, ye lubbers!" roared the technician.' "42"
JScript supports both integer and floatingpoint numbers. Integers can be positive, 0, or negative; a floatingpoint number can contain either a decimal point, an "e" (uppercase or lowercase), which is used to represent "ten to the power of" in scientific notation, or both. These numbers follow the IEEE 754 standard for numerical representation. Last, there are certain number values that are special:
 NaN, or not a Number
 Positive Infinity
 Negative Infinity
 Positive 0
 Negative 0
Integers can be represented in base 10 (decimal), base 8 (octal), and base 16 (hexadecimal).
Octal integers are specified by a leading "0", and can contain digits 0 through 7. If a number has a leading "0" but contains the digits "8" and/or "9", it is a decimal number. A number that would otherwise be an octal number but contains the letter "e" (or "E") generates an error.
Hexadecimal ("hex") integers are specified by a leading "0x" (the "X" can be uppercase or lowercase) and can contain digits 0 through 9 and letters A through F (either uppercase or lowercase). The letter "e" is a permissible digit in hexadecimal notation and does not signify an exponential number. The letters A through F are used to represent, as single digits, the numbers that are 10 through 15 in base 10. That is, 0xF is equivalent to 15, and 0x10 is equivalent to 16.
Octal and hexadecimal numbers can be negative, but cannot be fractional. A number that begins with a single "0" and contains a decimal point is a decimal floatingpoint number; if a number that begins with "0x" or "00" contains a decimal point, anything to the right of the decimal point is ignored.
Some example numbers:
.0001, 0.0001, 1e4, 1.0e4 // Four floatingpoint numbers, equivalent to each other. 3.45e2 // A floatingpoint number, equivalent to 345. 42 // An integer number. 0377 // An octal integer, equivalent to 255. 00.0001 // As octal numbers cannot have decimal parts, this is equivalent to 0. 0378 // An integer, equivalent to 378. 0Xff // A hexadecimal integer, equivalent to 255. 0x37CF // A hexadecimal integer, equivalent to 14287. 0x3e7 // A hexadecimal integer, equivalent to 999. 0x3.45e2 // As hexadecimal numbers cannot have decimal parts, this is equivalent to 3.
The possible Boolean values are true and false. These are special values, and are not usable as 1 and 0.
For more information on comparisons, see Controlling Program Flow.
Note In a comparison, any expression that evaluates to 0 is taken to be false, and any statement that evaluates to a number other than 0 is taken to be true. Thus the following expression evaluates to true:
(false == 0)
A value that is undefined is simply a value given to a variable after it has been created, but before a value has been assigned to it.
A null value is one that has no value and means nothing.
© 1997 by Microsoft Corporation. All rights reserved.
file: /Techref/inet/iis/jscript/htm/js7.htm, 5KB, , updated: 1997/9/30 04:45, local time: 2024/7/14 23:08, 
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.massmind.org/techref/inet/iis/jscript/htm/js7.htm"> JScript Data Types</A> 
Did you find what you needed? 
Welcome to massmind.org! 
Welcome to www.massmind.org! 
.