String
Last updated
Last updated
The String object is used to represent and manipulate a sequence of characters.
For more information see: .
Type | Name | Summary |
---|
Type | Name | Summary |
---|
Gives the length of the string.
Sample
returns a copy of the string embedded within an anchor <A> tag set.
Parameters
Sample
returns a copy of the string embedded within an <BIG> tag set.
Sample
returns a copy of the string embedded within an <BLINK> tag set.
Sample
returns a copy of the string embedded within an <B> tag set.
Sample
returns a character of the string.
Parameters
Sample
returns a decimal code of the char in the string.
Parameters
Sample
returns a non-negative integer that is the Unicode code point value at the given position. Note that this function does not give the nth code point in a string, but the code point starting at the specified string index.
Parameters
Sample
returns a string that appends the parameter string to the string.
Parameters
Sample
returns a string that appends the parameter string to the string.
Parameters
Sample
Determines whether a string ends with the characters of a specified string, returning true or false as appropriate.
Parameters
Sample
Determines whether a string ends with the characters of a specified string, returning true or false as appropriate.
Parameters
Sample
returns a boolean that checks if the given string is equal to the string
Parameters
Sample
returns a boolean that checks if the given string is equal to the string ignoring case
Parameters
Sample
returns a copy of the string embedded within an anchor <TT> tag set.
Sample
returns a copy of the string embedded within an <FONT> tag set, the color param is assigned the the color attribute.
Parameters
Sample
returns a copy of the string embedded within an <FONT> tag set, The size param is set to the SIZE attribute
Parameters
Sample
Static method that returns a string created from the specified sequence of UTF-16 code units.
Parameters
Sample
Static method that returns a string created by using the specified sequence of code points. String.fromCharCode() cannot return supplementary characters (i.e. code points 0x010000 – 0x10FFFF) by specifying their code point. Instead, it requires the UTF-16 surrogate pair for that. String.fromCodePoint(), on the other hand, can return 4-byte supplementary characters, as well as the more common 2-byte BMP characters, by specifying their code point (which is equivalent to the UTF-32 code unit).
RangeError is thrown if an invalid Unicode code point is given (e.g. "RangeError: NaN is not a valid code point").
Parameters
Sample
Determines whether one string may be found within another string.
Sample
returns the found index of the given string in string.
Parameters
Sample
returns a copy of the string embedded within an <I> tag set
Sample
returns the found index of the given string in string from the end.
Parameters
Sample
returns a copy of the string embedded within an <A> tag set.
Parameters
Sample
Parameters
Sample
returns an array of strings within the current string that matches the regexp.
Parameters
Sample
Returns the Unicode Normalization Form of the string. (defaults to "NFC" form)
Returns the Unicode Normalization Form of the string. form param can be one of "NFC", "NFD", "NFKC", or "NFKD", specifying the Unicode Normalization Form. If omitted or undefined, "NFC" is used.
These values have the following meanings:
"NFC" Canonical Decomposition, followed by Canonical Composition. "NFD" Canonical Decomposition. "NFKC" Compatibility Decomposition, followed by Canonical Composition. "NFKD" Compatibility Decomposition.
Parameters
Sample
The padEnd() method pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of the current string. The default value used for padding is the unicode "space" character (U+0020) - if no padString argument is used.
Parameters
Sample
The padEnd() method pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of the current string.
Parameters
Sample
The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start of the current string. The default value used for padding is the unicode "space" character (U+0020) - if no padString argument is used.
Parameters
Sample
The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start of the current string.
Parameters
Sample
Constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together.
Parameters
Sample
returns a new string where the matches of the given regexp are replaced by the return value of the function. The function parameter is the function to be invoked to create the new substring (to put in place of the substring received from parameter #1).
Parameters
Sample
returns a new string where the matches of the given reg exp are replaced by newSubStr.
Parameters
Sample
returns a new string where the first match of the given substr is replaced by the return value of the function. The function parameter is the function to be invoked to create the new substring (to put in place of the substring received from parameter #1).
Parameters
Sample
returns a new string where the first match of the given substr is replaced by newSubStr.
Parameters
Sample
returns an index where the first match is found of the regexp
Parameters
Sample
returns a substring of the string.
Parameters
Sample
returns a substring of the string.
Parameters
Sample
returns a copy of the string embedded within an <SMALL> tag set.
Sample
returns an array of objects whose elements are segments of the current string.
Parameters
Sample
returns an array of objects whose elements are segments of the current string.
Parameters
Sample
Determines whether a string begins with the characters of a specified string, returning true or false as appropriate.
Parameters
Sample
Determines whether a string begins with the characters of a specified string, returning true or false as appropriate.
Parameters
Sample
returns a copy of the string embedded within an <STRIKE> tag set.
Sample
returns a copy of the string embedded within an <SUB> tag set.
Sample
returns a substring of the string from the start with the number of chars specified.
Parameters
Sample
returns a substring of the string from the start with the number of chars specified.
Parameters
Sample
Returns a substring of the string from the start index until the end index.
Parameters
Sample
Returns a substring of the string from the start index until the end index.
Parameters
Sample
returns a copy of the string embedded within an <SUP> tag set.
Sample
Sample
Sample
returns a string with all lowercase letters of the current string.
Sample
returns a string with all uppercase letters of the current string.
Sample
Returns the string stripped of whitespace from both ends.
Sample
Removes whitespace from the ending of a string and returns a new string, without modifying the original string.
Sample
Removes whitespace from the beginning of a string and returns a new string, without modifying the original string.
Sample
Type
nameAttribute ;
Returns:
Returns:
Returns:
Returns:
index ;
Returns:
index ;
Returns:
index ;
Returns:
string2 ;
Returns:
string2 ;
stringN ;
Returns:
searchString The characters to be searched for at the end of str.
Returns: true if the given characters are found at the end of the string; otherwise, false
searchString The characters to be searched for at the end of str.
length If provided, it is used as the length of str. Defaults to str.length.
Returns: true if the given characters are found at the end of the string; otherwise, false
other ;
Returns:
other ;
Returns:
Returns:
color ;
Returns:
size ;
Returns:
num A sequence of numbers that are UTF-16 code units. The range is between 0 and 65535 (0xFFFF). Numbers greater than 0xFFFF are truncated. No validity checks are performed.
Returns: A string of length N consisting of the N specified UTF-16 code units.
num A sequence of code points.
Returns: A string created by using the specified sequence of code points.
Returns:
searchValue ;
fromIndex ;
Returns:
Returns:
searchValue ;
fromIndex ;
Returns:
hrefAttribute ;
Returns:
otherString ;
Returns:
regexp ;
Returns:
Returns: A string containing the Unicode Normalization Form of the given string.
form param can be one of "NFC", "NFD", "NFKC", or "NFKD",
Returns: A string containing the Unicode Normalization Form of the given string.
targetLength The length of the resulting string once the current str has been padded. If the value is less than or equal to str.length, then str is returned as-is.
Returns: A String of the specified targetLength with spaces applied at the end of the current str.
targetLength The length of the resulting string once the current str has been padded. If the value is less than or equal to str.length, then str is returned as-is.
padString The string to pad the current str with. If padString is too long to stay within the targetLength, it will be truncated from the end. The default value is the unicode "space" character (U+0020).
Returns: A String of the specified targetLength with the padString applied at the end of the current str.
targetLength The length of the resulting string once the current str has been padded. If the value is less than or equal to str.length, then str is returned as-is.
Returns: A String of the specified targetLength with spaces applied from the start.
targetLength The length of the resulting string once the current str has been padded. If the value is less than or equal to str.length, then str is returned as-is.
padString The string to pad the current str with. If padString is too long to stay within the targetLength, it will be truncated from the end. The default value is the unicode "space" character (U+0020).
Returns: A String of the specified targetLength with padString applied from the start.
count An integer between 0 and +Infinity, indicating the number of times to repeat the string.
Returns: A new string containing the specified number of copies of the given string.
regexp ;
function ;
Returns:
regexp ;
newSubStr ;
Returns:
substr ;
function ;
Returns:
substr ;
newSubStr ;
Returns:
regexp ;
Returns:
beginSlice ;
Returns:
beginSlice ;
endSlice ;
Returns:
Returns:
separator Specifies the string which denotes the points at which each split should occur. If separator is an empty string, str is converted to an array of characters.
limit Optional integer specifying a limit on the number of splits to be found.
Returns:
separator Specifies the string which denotes the points at which each split should occur. If separator is an empty string, str is converted to an array of characters.
limit Optional integer specifying a limit on the number of splits to be found.
Returns:
searchString The characters to be searched for at the start of this string.
Returns: true if the given characters are found at the beginning of the string; otherwise, false
searchString The characters to be searched for at the start of this string.
position The position in this string at which to begin searching for searchString. Defaults to 0.
Returns: true if the given characters are found at the beginning of the string; otherwise, false
Returns:
Returns:
start ;
Returns:
start ;
length ;
Returns:
indexA ;
Returns:
indexA ;
indexB ;
Returns:
Returns:
Returns:
Returns:
Returns:
Returns:
Returns:
Returns:
Returns:
Gives the length of the string. |
returns a copy of the string embedded within an anchor <A> tag set. |
returns a copy of the string embedded within an <BIG> tag set. |
returns a copy of the string embedded within an <BLINK> tag set. |
returns a copy of the string embedded within an <B> tag set. |
returns a character of the string. |
returns a decimal code of the char in the string. |
returns a non-negative integer that is the Unicode code point value at the given position. |
returns a string that appends the parameter string to the string. |
returns a string that appends the parameter string to the string. |
Determines whether a string ends with the characters of a specified string, returning true or false as appropriate. |
Determines whether a string ends with the characters of a specified string, returning true or false as appropriate. |
returns a boolean that checks if the given string is equal to the string |
returns a boolean that checks if the given string is equal to the string ignoring case |
returns a copy of the string embedded within an anchor <TT> tag set. |
returns a copy of the string embedded within an <FONT> tag set, the color param is assigned the the color attribute. |
returns a copy of the string embedded within an <FONT> tag set, The size param is set to the SIZE attribute |
Static method that returns a string created from the specified sequence of UTF-16 code units. |
Static method that returns a string created by using the specified sequence of code points. |
Determines whether one string may be found within another string. |
returns the found index of the given string in string. |
returns a copy of the string embedded within an <I> tag set |
returns the found index of the given string in string from the end. |
returns a copy of the string embedded within an <A> tag set. |
returns an array of strings within the current string that matches the regexp. |
Returns the Unicode Normalization Form of the string. |
Returns the Unicode Normalization Form of the string. |
The padEnd() method pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. |
The padEnd() method pads the current string with a given string (repeated, if needed) so that the resulting string reaches a given length. |
The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. |
The padStart() method pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. |
Constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated together. |
returns a new string where the matches of the given regexp are replaced by the return value of the function. |
returns a new string where the matches of the given reg exp are replaced by newSubStr. |
returns a new string where the first match of the given substr is replaced by the return value of the function. |
returns a new string where the first match of the given substr is replaced by newSubStr. |
returns an index where the first match is found of the regexp |
returns a substring of the string. |
returns a substring of the string. |
returns a copy of the string embedded within an <SMALL> tag set. |
returns an array of objects whose elements are segments of the current string. |
returns an array of objects whose elements are segments of the current string. |
Determines whether a string begins with the characters of a specified string, returning true or false as appropriate. |
Determines whether a string begins with the characters of a specified string, returning true or false as appropriate. |
returns a copy of the string embedded within an <STRIKE> tag set. |
returns a copy of the string embedded within an <SUB> tag set. |
returns a substring of the string from the start with the number of chars specified. |
returns a substring of the string from the start with the number of chars specified. |
Returns a substring of the string from the start index until the end index. |
Returns a substring of the string from the start index until the end index. |
returns a copy of the string embedded within an <SUP> tag set. |
returns a string with all lowercase letters of the current string. |
returns a string with all uppercase letters of the current string. |
Returns the string stripped of whitespace from both ends. |
Removes whitespace from the ending of a string and returns a new string, without modifying the original string. |
Removes whitespace from the beginning of a string and returns a new string, without modifying the original string. |