Previous PageNext Page

String Object

The String object enables manipulation and formatting of text strings and determination and location of substrings within strings.

Methods

anchor

Places an HTML anchor tag (<A>) with a NAME attribute around text.

big

Places HTML <BIG> tags around text.

blink

Places HTML <BLINK> tags around text.

bold

Places HTML <B> tags around text.

charAt

Retrieves the character as the specified index.

charCodeAt

Returns the Unicode encoding of the specified character.

concat

Combines two strings into one String object.

fixed

Places HTML <TT> tags around text.

fontcolor

Places an HTML <FONT> tag with the COLOR attribute around text.

fontsize

Places an HTML <FONT> tag with the SIZE attribute around text.

fromCharCode

Creates a string from a number of Unicode character values.

indexOf

Finds the first occurrence of a .

italics

Places HTML <I> tags around text.

lastIndexOf

Finds the last occurrence of a substring.

link

Places an HTML anchor tag (<A>) with an HREF attribute around text.

match

Performs a search on a string using the supplied Regular Expression object.

replace

Replaces the text found by a regular expression with other text.

search

Searches a string for matches to a regular expression.

slice

Returns a section of a string.

small

Places HTML <SMALL> tags around text.

split

Removes text from a string.

strike

Places HTML <STRIKE> tags around text.

sub

Places HTML <SUB> tags around text.

substr

Returns a substring beginning at a specified location and having a specified length.

substring

Returns the substring at a specified location.

sup

Places HTML <SUP> tags around text.

toLowerCase

Converts text to lowercase letters.

toUpperCase

Converts text to uppercase letters.

Properties

length

The length of a String object.

Syntax

StringObj[.method]

"String Literal"[.method]

Arguments

method
A String object method.

Remarks

String objects can be created implicitly using string literals. String objects created in this fashion (referred to as standard strings) are treated differently than String objects created using the new operator. All string literals share a common, global string object. So, if a property is added to a string literal, it is available to all standard string objects:

var alpha, beta;

alpha = "This is a string";

beta = "This is also a string";

alpha.test = 10;

In this example, test is now defined for beta and all future string literals. In the following example, however, added properties are treated differently:

var gamma, delta;

gamma = new String("This is a string");

delta = new String("This is also a string");

gamma.test = 10;

In this case, test is not defined for delta. Each String object declared as a new String object has its own set of members. This is the only case where String objects and string literals are handled differently.


Copyright © 2000 Chili!Soft

Previous PageTop Of PageNext Page