String (Primitive value)

A built-in primitive value.

Availability:

ECMAScript edition - 2
Property/method value type:String primitive

A string value is a member of the type String and is a finite ordered sequence of zero or more Unicode characters. There is no way to represent a single character other than by means of a very short string.

A string is not an array of characters as it would be in the C language. It is also not mutable as the other object data types that are passed by reference are. Strings are immutable and therefore to change one, you must manufacture a new string and discard the old one. This can lead to memory leaks.

Strings can contain any Unicode character code point, however, many are not available on even the most international keyboard and must be escaped. You will need to check that the host environment can render the international symbols correctly if you use them.

Strings can be delimited by either single or double quotes. This can be very useful for the occasions when a fragment of JavaScript is contained within some HTML.

Refer to the String literal topic for a list of escape characters and more information on defining string values.

Warnings:

See also:<SCRIPT>, Cast operator, java.lang.String, JavaScript to Java values, String concatenate (+), String literal

Cross-references:

ECMA 262 edition 2 - section 4.3.16

ECMA 262 edition 3 - section 4.3.16

Wrox Instant JavaScript - page 14