A String object, created using the String constructor, represents a series of characters in a string. The string can be enclosed between single or double quotes.
myString = new String("This is a string object")
This code shows the use of the String constructor to create a String object called 'myString'.
Syntax: Object.constructor
This specifies a function to create an object's property and is inherited by all objects from their prototype.
Syntax: object.length
This property returns the length of the string.
Syntax: Object.prototype.name = value
This allows the addition of properties and methods to any object.
Syntax: object.anchor("name")
This method is used to create an HTML anchor.
Syntax: object.'formatting_method'( )
This method displays the string using a big font, as if contained within HTML <BIG></BIG> tags.
Syntax: object.'formatting_method'( )
This method makes the displayed string blink, as if contained within HTML <BLINK></BLINK> tags.
Syntax: object.'formatting_method'( )
This method displays the string using a bold font, as if contained within HTML <B></B> tags.
Syntax: object.charAt(index)
This method returns a character from a string by referring to its index within that string.
Syntax: object.charCodeAt(index)
This method returns a character's Unicode value from a string by referring to its index within that string.
Syntax: object.concat(strName2, strName3....strName[n])
This method joins the text contained in one string with the text from other specified strings and returns a new string.
Syntax: Object.eval(string)
The eval method is deprecated as a method of Object, but is still used as a high level function. It evaluates a string of JavaScript in the context of an object.
Syntax: object.'formatting_method'( )
This method displays the string using a fixed-pitch font, as if contained within HTML <TT></TT> tags.
Syntax: object.'formatting_method'( )
This method displays the string using a specified color, as if contained within HTML <FONT COLOR="color"></FONT> tags.
Syntax: object.'formatting_method'( )
This method displays the string using a specified font size, as if contained within HTML <FONT SIZE="fontsize"></FONT> tags.
Syntax: String.fromCharCode(num1,...,numN)
This method takes the specified Unicode values and returns a string (but not a String object).
Syntax: object.indexOf(searchValue,[fromIndex])
When called from a String object, this method returns the index of the first occurance of the specified searchValue argument, starting from the specified fromIndex argument.
Syntax: object.'formatting_method'( )
This method displays the string using italics, as if contained within HTML <I></I> tags.
Syntax: object.lastIndexOf(searchValue,[fromIndex])
When called from a String object, this method returns the index of the last occurance of the specified searchValue argument, searching backwards from the specified fromIndex argument.
Syntax: object.link("targetURL")
This method is used to create an HTML hyperlink in a document.
Syntax: object.match(regexp)
This method is used to match a specified regular expression against a string.
Syntax: object.replace(regexp,
newSubStr)
object.replace(regexp,
function)
This method is used to match a specifed regular expression against a string and replace any match with a new substring.
Syntax: object.search(regexp)
This method is used to search for a match between a regular expression and the specified string.
Syntax: object.slice(startSlice[, endSlice])
This method is used to 'slice' a section of a string and return a new string containing that section.
Syntax: object.'formatting_method'( )
This method displays the string using a small font, as if contained within HTML <SMALL></SMALL> tags.
Syntax: object.split [delimiter]
This method splits a string into substrings and creates an array containing the resulting substrings.
Syntax: object.'formatting_method'( )
This method displays the string using struck-out text, as if contained within HTML <STRIKE></STRIKE> tags.
Syntax: object.'formatting_method'( )
This method displays the string as subscript text, as if contained within HTML <SUB></SUB> tags.
Syntax: object.substr(start[, length])
This method extracts the characters from a string beginning at the specified start index for the specified number of characters.
Syntax: object.substring(indexA, indexB)
This method returns the characters in a string between two specified indices as a substring.
Syntax: object.'formatting_method'( )
This method displays the string as superscript text, as if contained within HTML <SUP></SUP> tags.
Syntax: object.toLowerCase( )
This method is used to convert the characters in a string to lower case.
Syntax: Object.toSource()
The toSource method returns a literal representing the source code of an object. This can then be used to create a new object.
Syntax: Object.toString()
The toString method returns a string representing a specified object.
Syntax: object.toUpperCase( )
This method is used to convert characters in a string to upper case.
Syntax: Object.unwatch(property)
This method removes a watchpoint set for an object and property name with the watch method.
Syntax: Object.valueOf()
This method returns a primitive value for a specified object.
Syntax: Object.watch(property, handlerfunction)
This method adds a watchpoint to a property of the object.