template literal or string interpolation
uppercase and lowercase
slice()
the slice() method extracts a section of the string and returns it as a new string, without modifying the original string.
replace() and replaceAll()
The replace()
method of String
values returns a new string with one, some, or all matches of a pattern
replaced by a replacement
. The pattern
can be a string or a RegExp
, and the replacement
can be a string or a function called for each match. If pattern
is a string, only the first occurrence will be replaced. The original string is left unchanged.
The replaceAll()
method of String
values returns a new string with all matches of a pattern
replaced by a replacement
. The pattern
can be a string or a RegExp
, and the replacement
can be a string or a function to be called for each match. The original string is left unchanged.
concat()
The concat()
method of String
values concatenates the string arguments to this string and returns a new string.
trim(), trimEnd() and trimStart()
The trim()
method of String
values removes whitespace from both ends of this string and returns a new string, without modifying the original string. To return a new string with whitespace trimmed from just one end, use trimStart()
or trimEnd()
.
The trimEnd()
method of String
values removes whitespace from the end of this string and returns a new string, without modifying the original string. trimRight()
is an alias of this method.
The trimStart()
method of String
values removes whitespace from the beginning of this string and returns a new string, without modifying the original string. trimLeft()
is an alias of this method.
for...in loop
at()
The at()
method of String
values takes an integer value and returns a new String
consisting of the single UTF-16 code unit located at the specified offset. This method allows for positive and negative integers. Negative integers count back from the last string character.
endsWith()
The endsWith()
method of String
values determines whether a string ends with the characters of this string, returning true
or false
as appropriate.
startsWith()
The startsWith()
method of String
values determines whether a string begins with the characters of a specified string, returning true
or false
as appropriate.
repeat()
The repeat()
method of String
values constructs and returns a new string which contains the specified number of copies of this string, concatenated together.
valueOf()
split()
The split()
method of String
values takes a pattern and divides this string into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.
includes()
The includes()
method of String
values performs a case-sensitive search to determine whether a given string may be found within this string, returning true
or false
as appropriate.