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.
Beware that the HTML escaping rules come into play when JavaScript is contained within HTML quote delimited name-value pairs in tags and you must be careful to escape any characters within scripts using the JavaScript escape mechanisms and not the HTML escape mechanisms. JavaScript inside <SCRIPT> tags may also be affected by the host environment's escaping mechanisms.
ECMA 262 edition 2 - section 4.3.16
ECMA 262 edition 3 - section 4.3.16
Wrox Instant JavaScript - page 14
Prev | Home | Next |
String | Up | String concatenate (+) |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |