String Reference
This section provides a comprehensive guide to JavaScript string methods and properties. It is designed for quick reference and easy understanding, helping developers efficiently work with strings while coding. The content has been updated for clarity and completeness as of July 2025
Name | Description |
---|---|
at() | Returns the character at the specified index in a string. |
charAt() | Returns the character at a specified index (position). |
charCodeAt() | Returns the Unicode of the character at a specified index. |
codePointAt() | Returns the Unicode code point at a given index. |
concat() | Combines two or more strings and returns a new string. |
constructor | Returns the constructor function of the string. |
endsWith() | Checks if a string ends with a specified value. |
fromCharCode() | Converts Unicode values to characters. |
includes() | Checks if a string contains a specified value. |
indexOf() | Returns the index of the first occurrence of a specified value. |
isWellFormed() | Returns true if the string is well-formed. |
lastIndexOf() | Returns the index of the last occurrence of a specified value. |
length | Returns the length of the string. |
localeCompare() | Compares two strings according to the current locale. |
match() | Searches a string using a value or regular expression and returns matches. |
matchAll() | Returns an iterator of all matches for a value or regular expression. |
padEnd() | Pads a string at the end to reach a target length. |
padStart() | Pads a string at the start to reach a target length. |
prototype | Allows adding properties or methods to the string object. |
repeat() | Returns a new string repeating the original string a number of times. |
replace() | Replaces the first match of a pattern in a string. |
replaceAll() | Replaces all matches of a pattern in a string. |
search() | Searches a string using a value or regular expression and returns the index. |
slice() | Extracts a portion of a string and returns a new string. |
split() | Splits a string into an array of substrings. |
startsWith() | Checks whether a string begins with specified characters. |
substr() | Deprecated. Use substring() or slice() instead. |
substring() | Extracts characters between two specified indices. |
toLocaleLowerCase() | Converts the string to lowercase using the host’s locale. |
toLocaleUpperCase() | Converts the string to uppercase using the host’s locale. |
toLowerCase() | Converts the string to lowercase. |
toString() | Returns the string or string object as a string. |
toUpperCase() | Converts the string to uppercase. |
toWellFormed() | Replaces "lone surrogates" with the Unicode replacement character. |
trim() | Removes whitespace from both ends of the string. |
trimEnd() | Removes whitespace from the end of the string. |
trimStart() | Removes whitespace from the start of the string. |
valueOf() | Returns the primitive value of a string object. |