JavaScript String Methods Flashcards
length
shows the size
.concat()
merges two string and creates one
.padStart(targetLength, padString)/padEnd(targetLength, padString)
adds elements to the start or to the end
.at(index)
takes an integer value and returns a new String consisting of the single UTF-16 code unit located at the specified offset.
startsWith(searchString, endPosition)/endsWith(searchString, endPosition)
determines whether a string starts or ends with the characters of this string, returns true or false as appropriate.
.includes( searchString, position)
performs a case-sensitve search to determines whether a given string may be found within this string, returning true or false as appropriate.
indexOf(searchString, position)
Searches this string and returns the index of the first occurrence of the specified substring.
.match( regexp )
finds the matching string against a regular expression.
.repeat( count )
Returns a new string which contains the specified number of copies of this string, concatenated together.
replace(pattern, replacement)
Returns a new string with one, some, or all matches of a pattern replaced by a replacement.
replaceAll(pattern, replacement)
Returns a new string with all matches of a pattern replaced by a replacement.
search(regexp)
Executes a search for a match between a regular expression and this string, returning the index of the first match in the string.
slice(start, end)
Extracts a section of this string and returns it as a new string, without modifying the original string.
.split(separator, limit)
Divides this string into an ordered list of substrings by searching for the pattern, puts these substrings into an array, and returns the array.
trim()
Removes whitespace from both ends of this string and returns a new string, without modifying the original string.