Share this Page URL

Constant Number.MAX_VALUE Number.MIN_VALUE Number.NaN Number.POSITIVE_INFINITY Number.NEGATIVE_INFINITY Meaning Largest representable number Smallest (closest to zero) representable number Special not-a-number value Special value to represent infinity Special value to represent negative infinity The Infinity and NaN constants are defined by the ECMAScript v1 standard and are not implemented prior to JavaScript 1.3. The various Number constants, however, have been implemented since JavaScript 1.1. Strings A string is a sequence of Unicode letters, digits, punctuation characters, and so on -- it is the JavaScript data type for representing text. As you'll see shortly, you can include string literals in your programs by enclosing them in matching pairs of single or double quotation marks. Note that JavaScript does not have a character data type such as char , like C, C++, and Java do. To represent a single character, you simply use a string that has a length of 1. String Literals A string is a sequence of zero or more Unicode characters enclosed within single or double quotes ( ' or " ). Double-quote characters may be contained within strings de- limited by single-quote characters, and single-quote characters may be contained within strings delimited by double quotes. String literals must be written on a single line; they may not be broken across two lines. If you need to include a newline character in a string literal, use the character sequence \n , which is documented in the next section. Examples of string literals are: "" // The empty string: it has zero characters 'testing' "3.14" 'name="myform"' "Wouldn't you prefer O'Reilly's book?" "This string\nhas two lines" "pi is the ratio of a circle's circumference to its diameter" As illustrated in the last example string shown, the ECMAScript v1 standard allows Unicode characters within string literals. Implementations prior to JavaScript 1.3, however, typically support only ASCII or Latin-1 characters in strings. As we'll see in the next section, you can also include Unicode characters in your string literals using special "escape sequences." This is useful if your text editor does not provide complete Unicode support. Strings | 33