JavaScript Editor Ajax toolkit     Ajax website 

Main Page

A string value is a chain of zero or more concatenated, Unicode characters (letters, digits, and punctuation marks). The string data type represents text in JScript. To include string literals in your scripts, enclose them in matching pairs of single or double quotation marks. Double quotation marks can be contained within strings surrounded by single quotation marks, and single quotation marks can be contained within strings surrounded by double quotation marks. The following are examples of strings:

Using String Data

В CopyCode imageCopy Code
"The earth is round."
'"Come here, Watson. I need you." said Alexander.' 

JScript provides escape sequences that you can include in strings to create characters that you cannot type directly. Each of these sequences begins with a backslash. The backslash is an escape character that informs the JScript interpreter that the next character is special.

Escape sequence Meaning




Form feed (rarely used)


Line feed (newline)


Carriage return. Use with the line feed (\r\n) to format output.


Horizontal tab


Vertical tab. Not compliant with ECMAScript standard and incompatible with Microsoft Internet Explorer 6.0.


Single quote (')


Double quote (")


Backslash (\)


ASCII character represented by the octal number n. The value of n must be in the range 0 to 377 (octal).


ASCII character represented by the two-digit hexadecimal number hh.


Unicode character represented by the four-digit hexadecimal number hhhh.

Any escape sequence not included in this table simply codes for the character that follows the backslash in the escape sequence. For example, "\a" is interpreted as "a".

Since the backslash itself represents the start of an escape sequence, you cannot directly type one in your script. If you want to include a backslash, you must type two sequential characters (\\).

В CopyCode imageCopy Code
'The image path is C:\\webstuff\\mypage\\gifs\\garden.gif.'

The single-quote and double-quote escape sequences can be used to include quotes in string literals. This example shows embedded quotes.

В CopyCode imageCopy Code
'The caption reads, \"After the snow of \'97. Grandma\'s house is covered.\"'

JScript uses the intrinsic char data type to represent a single character. A string containing one character or one escape sequence can be assigned to a variable of type char, although the string is not itself of type char.

A string that contains zero characters ("") is an empty (zero-length) string.

See Also

JavaScript Editor Ajax toolkit     Ajax website