String (Type)

A native built-in type.

Availability:

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

Entities of type String are collections of zero or more Unicode characters.

A string is arranged so that the characters in it can be accessed by their position. The leftmost character is considered to be at position 0 and the right most character is therefore at a position whose value is one less than the length of the string.

This is convenient when processing strings in a for() loop since you can check the enumerator against the length and as long as it is less than the length and is a positive value, it is indexing within the string.

Zero length strings are a special case.

Strings can only be accessed read-only. You cannot change the contents of a string, you can only replace it with another.

Warnings:

See also:Cast operator, Data Type, Fundamental data type, String concatenate (+), toString(), Type, Type conversion, Unicode

Cross-references:

ECMA 262 edition 2 - section 4.3.17

ECMA 262 edition 2 - section 6

ECMA 262 edition 2 - section 8.4

ECMA 262 edition 3 - section 4.3.17

ECMA 262 edition 3 - section 8.4

O'Reilly JavaScript Definitive Guide - page 38

O'Reilly JavaScript Definitive Guide - page 50