String
Properties
str.length
- Reflects the length of the string.
N
- Used to access the character in the Nth position where N is a positive integer between 0 and one less than the value of
length
. These properties are read-only.
Methods
str.charAt()
- Returns the character at the specified index.
str.charCodeAt()
- Returns a number indicating the Unicode value of the character at the given index.
str.concat()
- Combines the text of two strings and returns a new string.
str.indexOf()
- Returns the index within the calling
String
object of the first occurrence of the specified value, or -1 if not found.
str.lastIndexOf()
- Returns the index within the calling
String
object of the last occurrence of the specified value, or -1 if not found.
str.localeCompare()
- Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
str.match()
- Used to match a regular expression against a string.
str.replace()
- Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
str.search()
- Executes the search for a match between a regular expression and a specified string.
str.slice()
- Extracts a section of a string and returns a new string.
str.split()
- Splits a
String
object into an array of strings by separating the string into substrings.
str.substr()
- Returns the characters in a string beginning at the specified location through the specified number of characters.
str.substring()
- Returns the characters in a string between two indexes into the string.
str.toLocaleLowerCase()
- The characters within a string are converted to lower case while respecting the current locale. For most languages, this will return the same as
toLowerCase()
.
str.toLocaleUpperCase()
- The characters within a string are converted to upper case while respecting the current locale. For most languages, this will return the same as
toUpperCase()
.
str.toLowerCase()
- Returns the calling string value converted to lower case.
str.toSource()
- Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the
Object.prototype.toSource()
method.
str.toString()
- Returns a string representing the specified object. Overrides the
Object.prototype.toString()
method.
str.toUpperCase()
- Returns the calling string value converted to uppercase.
str.trim()
- Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.
str.trimLeft()
- Trims whitespace from the left side of the string.
str.trimRight()
- Trims whitespace from the right side of the string.
str.valueOf()
- Returns the primitive value of the specified object. Overrides the
Object.prototype.valueOf()
method.
Created by Mozilla Contributors, license: CC-BY-SA 2.5