String Methods
Methods available on every JavaScript String instance.
String.fromCodePoint()
Returns a string created from the specified sequence of Unicode code points.
String.fromCodePoint(...codePoints) String.prototype..substring()
Extracts a portion of a string between two indices and returns a new string.
string.substring(start[, end]) String.prototype.at()
Return the character at a specified index, supporting negative indices to count from the end.
at(index) String.prototype.charAt()
Return the character at a specified index in a string.
charAt(index) String.prototype.charCodeAt()
Return the Unicode value (UTF-16 code unit) at a specified index in a string.
charCodeAt(index) String.prototype.codePointAt()
Get the Unicode code point value at a given position in a string, handling surrogate pairs correctly.
codePointAt(index) String.prototype.concat()
Merge two or more strings into one. Returns a new string containing all given strings joined together.
concat(...strings) String.prototype.endsWith()
Check if a string ends with a substring using the endsWith() method.
endsWith(searchString, endPosition) String.prototype.includes()
Check if a string contains a substring, returning true or false.
includes(searchString[, position]) String.prototype.indexOf()
Search for a substring within a string from the start and return its position, or -1 if not found.
indexOf(searchString, fromIndex?) String.prototype.lastIndexOf()
Search for a substring within a string from the end and return its last position, or -1 if not found.
lastIndexOf(searchString, fromIndex?) String.prototype.localeCompare()
Compare two strings in a locale-aware way for sorting and searching.
localeCompare(compareString[, locales[, options]]) String.prototype.match()
Search strings using regular expressions with the match() method in JavaScript.
str.match(regexp) String.prototype.matchAll()
Search strings using regular expressions with matchAll() for iterator-based capture group access.
str.matchAll(regexp) String.prototype.normalize()
Normalize Unicode text to a canonical form for proper string comparison and matching.
normalize([form]) String.prototype.padEnd()
Pad a string with a specified character until it reaches a target length. Perfect for fixed-width alignment in tables and CLI output.
str.padEnd(targetLength[, padString]) String.prototype.padStart()
Pad a string from the beginning until it reaches a target length. Essential for fixed-width alignment, numeric formatting, and creating uniform output.
str.padStart(targetLength[, padString]) String.prototype.repeat()
Returns a new string containing the specified number of copies of the original string concatenated together.
repeat(count) String.prototype.replace()
Replace a substring or pattern in a string with a replacement string or function.
replace(pattern, replacement) String.prototype.replaceAll()
Replace all occurrences of a substring or pattern in a string, returning a new string with all replacements made.
replaceAll(searchFor, replaceWith) String.prototype.search()
Search for a pattern in a string and return the index of the first match, or -1 if not found.
search(regexp) String.prototype.slice()
Extract a portion of a string from start to end index (exclusive), returning a new string.
slice(start[, end]) String.prototype.split()
Split a string into an array of substrings using a separator pattern.
String.prototype.startsWith()
Check if a string begins with a specified substring. Returns true or false.
startsWith(searchString[, position]) String.prototype.toLowerCase()
Convert a string to lowercase with this fundamental JavaScript string method.
toLowerCase() String.prototype.toUpperCase()
Convert a string to uppercase.
toUpperCase() String.prototype.trim()
Remove whitespace from both ends of a string, returning a new string without modifying the original.
trim() String.prototype.trimEnd()
Remove whitespace from the end of a string, returning a new string without modifying the original.
trimEnd() String.prototype.trimStart()
Remove whitespace from the beginning of a string, returning a new string without modifying the original.
trimStart()