Java Reference
In-Depth Information
String
The String object is used to contain a string of characters. It was introduced in JavaScript 1.0. This
must be distinguished from a string literal, but the methods and properties of the String object can also
be accessed by a string literal, since a temporary object will be created when they are called.
The HTML methods in the last table are not part of any ECMAScript standard, but they have been part of
the JavaScript language since version 1.0. They can be useful because they dynamically generate HTML.
Properties
Property
Introduced
Description
constructor
JavaScript 1.1
Used to reference the constructor function for the object.
length
JavaScript 1.0
Returns the number of characters in the string.
prototype
JavaScript 1.1
Returns the prototype for the object, which can be used to
extend the object's interface.
Methods
Method
Introduced
Description
charAt(index)
JavaScript 1.0
Returns the character at the specifi ed position in
the string.
charCodeAt(index)
JavaScript 1.2
Returns the Unicode value of the character at the
specifi ed position in the string.
concat(value1,
value2, ...)
JavaScript 1.2
Concatenates the strings supplied as arguments
and returns the string thus formed.
fromCharCode(value1,
value2, ...)
JavaScript 1.2
Returns the string formed from the concatena-
tion of the characters represented by the sup-
plied Unicode values.
indexOf(substr
[, startIndex])
JavaScript 1.0
Returns the position within the String object
of the fi rst match for the supplied substring.
Returns -1 if the substring is not found. Starts
the search at startIndex if specifi ed.
lastIndexOf(substr
[, startIndex])
JavaScript 1.0
Returns the position within the String object
of the last match for the supplied substring.
Returns -1 if the substring is not found. Starts
the search at startIndex if specifi ed.
match(regexp)
JavaScript 1.2
Searches the string for a match to the supplied
pattern. Returns an array or null if not found.
Search WWH ::




Custom Search