Returns a number indicating whether the current String sorts before, the same as, or after the parameter other, based on browser and system-dependent string localization.
Returns an array of String instances created by splitting the current String based on the regular expression and limited in size by the limit parameter.
Returns the Unicode code point at the given position index. The index is a position within the string in UTF-16
encoding. If the index points to the begin of a surrogate pair the only the code unit at the position is returned.
If the index is invalid undefined is returned.
Parameters:
index - The index of the starting code unit within the string.
Returns:
The Unicode code point, an UTF-16 code unit or undefined.
Returns the index of substring in this String object using
the specified start value as the location to begin searching.
If there is no match, -1 is returned.
Parameters:
substring - the String to search for in this String.
start - the location in the String from which to begin the search.
Returns the last index of substring in this String object,
using the specified start position as the location from which
to begin the search.
If there is no match, -1 is returned.
Parameters:
substring - the String to search for in this String.
start - the location from which to begin the search.
Returns a number indicating whether the current String sorts before, the same as,
or after the parameter other, based on browser and system-dependent
string localization.
Parameters:
other - the String to compare against this String.
Returns:
a number indicating whether the current String sorts before, the same as,
or after the parameter other.
Returns the normalized form of this Unicode string according to the standard as described in https://unicode.org/reports/tr15/.
In a normalized string, identical text is replaced by identical sequences of code points.
Parameters:
form - The normalization variant to use. Must be one of 'NFC', 'NFD', 'NFKC', 'NFKD'.
Appends space characters to the current string to ensure the resulting string reaches the given target length.
Parameters:
targetLength - The length to be reached.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength ending with space characters.
Appends a string (possibly multiple times) to the current string to ensure the resulting string reaches the given target length.
Parameters:
targetLength - The length to be reached.
fillString - The string providing the characters to be used for filling.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength with the (possibly multiple times) added and truncated fillString.
Prepends space characters to the current string to ensure the resulting string reaches the given target length.
Parameters:
targetLength - The length to be reached.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength starting with space characters.
Prepends a string (possibly multiple times) to the current string to ensure the resulting string reaches the given target length.
Parameters:
targetLength - The length to be reached.
fillString - The string providing the characters to be used for filling.
Returns:
This string if the string length is already greater than or equal to the target length. Else a new string with the targetLength with the (possibly multiple times) added and truncated fillString.
The static String.raw() method is a tag function of template literals.
It can be used in different ways:
1String.raw`Hello\n${40+2}!`;2// returns: Hello\n42!3// \ is here not an escape character like in string literals45String.raw({ raw: ['a', 'b', 'c'] }, '-', '.' );6// returns: a-b.c
Parameters:
callSite - A well-formed template call site object, like { raw: ['a', 'b', 'c'] }.
substitutions - The substitution values.
Returns:
A string constructed by the template with filled substitutions.
Returns a new String that results when matches of the regexp
parameter are replaced by using the specified function. The
original String is not modified so you must capture the new String
in a variable to preserve changes. When you specify a function as the
second parameter, the function is invoked after the match has been performed.
Parameters:
regexp - the regular expression to use.
function - a Function that operates on matches of regexp in the current String.
Returns:
a new String that results when matches of the regexp
parameter are replaced by the function.
Returns a new String that results when matches of the regexp
parameter are replaced by the replacement parameter. The
original String is not modified so you must capture the new String
in a variable to preserve changes. If regexp has the global flag set,
all occurrences are replaced, if the global flag is not set only the
first occurrence is replaced.
Parameters:
regexp - the regular expression to use.
replacement - a String that is to take the place of all matches of regexp in the current String.
Returns:
a new String that results when matches of the regexp
parameter are replaced by the replacement.
Returns a new String that results when matches of the literal
parameter are replaced by using the specified function. The
original String is not modified so you must capture the new String
in a variable to preserve changes. When you specify a function as the
second parameter, the function is invoked after the match has been
performed.
Parameters:
literal - the literal string to locate.
function - a Function that operates on the match of literal in the current String.
Returns:
a new String that results when the first match of the literal
parameter is replaced by the specified function.
Returns a new String that results when matches of the literal
parameter are replaced by using the specified function. The
original String is not modified so you must capture the new String
in a variable to preserve changes. When you specify a function as the
second parameter, the function is invoked after the match has been
performed.
Parameters:
literal - the literal string to locate.
function - a Function that operates on the match of literal in the current String.
flags - a String containing any combination of the Regular Expression flags of g - global match, i - ignore case, m - match over multiple lines.
Returns:
a new String that results when the first match of the literal
parameter is replaced by the specified function.
Returns a new String that results when matches of the literal
parameter are replaced by the replacement parameter. The
original String is not modified so you must capture the new String
in a variable to preserve changes. This method only replaces the first
occurrence of the literal. To replace all occurrences see the polymorphic
method with a regular expression as argument.
Parameters:
literal - the literal string to locate.
replacement - a String that is to take the place of all matches of regexp in the current String.
Returns:
a new String that results when the first match of the literal
parameter is replaced by the replacement parameter.
Returns a new String that results when matches of the literal
parameter are replaced by the replacement parameter. The
original String is not modified so you must capture the new String
in a variable to preserve changes. This method only replaces the first
occurrence of the literal. To replace all occurrences see the polymorphic
method with a regular expression as argument. Note that if flags
Parameters:
literal - the literal string to locate.
replacement - a String that is to take the place of all matches of regexp in the current String.
flags - a String containing any combination of the Regular Expression flags of g - global match, i - ignore case, m - match over multiple lines.
Returns:
a new String that results when the first match of the literal
parameter is replaced by the replacement parameter.
Searches for a match between the passed regular expression and this
string and returns the zero-based index of the match, or -1 if no match
is found.
Parameters:
regexp - the regular expression to use.
Returns:
the zero-based indexed value of the first character in the
current string that matches the pattern of the regular expression
regexp, or -1 if no match is found.
Returns an array of String instances created by splitting the current
String based on the regular expression and limited in size by the limit
parameter.
Parameters:
regexp - the regular expression to use to split the string.
limit - controls the maximum number of items that will be returned.
Returns:
an array of String instances created by splitting the current
String based on the regular expression and limited in size by the limit
parameter.