JavaScript String Functions and Properties
Here is a complete list of string functions (methods) and properties in JavaScript:
String Methods (Functions)
charAt(index)
- Returns the character at the specified index.
charCodeAt(index)
- Returns the Unicode of the character at the specified index.
codePointAt(index)
- Returns the code point of the character at the specified index (ES6).
concat(string1, string2, ...)
- Concatenates one or more strings.
includes(searchString, position)
- Checks if a string contains a specified string (ES6).
endsWith(searchString, length)
- Checks if a string ends with a specified string (ES6).
indexOf(searchValue, fromIndex)
- Returns the index of the first occurrence of the specified string.
lastIndexOf(searchValue, fromIndex)
- Returns the index of the last occurrence of the specified string.
localeCompare(compareString)
- Compares two strings in the current locale.
match(regexp)
- Searches a string for a match against a regular expression.
matchAll(regexp)
- Returns an iterator for all matches against a regular expression (ES2020).
normalize(form)
- Returns the Unicode normalization form of a string (ES6).
padEnd(targetLength, padString)
- Pads the current string with another string until it reaches the target length (ES2017).
padStart(targetLength, padString)
- Pads the current string from the start with another string (ES2017).
repeat(count)
- Returns a new string that repeats the original string
count
times (ES6).
- Returns a new string that repeats the original string
replace(searchValue, newValue)
- Replaces the first occurrence of a string or regex pattern with a new string.
replaceAll(searchValue, newValue)
- Replaces all occurrences of a string or regex pattern (ES2021).
search(regexp)
- Searches for a match between the string and a regular expression.
slice(startIndex, endIndex)
- Extracts a part of a string.
split(separator, limit)
- Splits a string into an array of substrings.
startsWith(searchString, position)
- Checks if a string starts with a specified string (ES6).
substring(startIndex, endIndex)
- Extracts characters between two indices.
toLowerCase()
- Converts a string to lowercase.
toUpperCase()
- Converts a string to uppercase.
trim()
- Removes whitespace from both sides of a string.
trimStart()
/trimLeft()
- Removes whitespace from the beginning of a string (ES2019).
trimEnd()
/trimRight()
- Removes whitespace from the end of a string (ES2019).
toLocaleLowerCase()
- Converts a string to lowercase according to the host’s current locale.
toLocaleUpperCase()
- Converts a string to uppercase according to the host’s current locale.
valueOf()
- Returns the primitive value of a
String
object.
- Returns the primitive value of a
toString()
- Returns a string representing the object.
fromCharCode(...codes)
(Static Method)- Converts Unicode values to characters.
fromCodePoint(...codePoints)
(Static Method)- Converts Unicode code points to characters (ES6).
raw(template, ...substitutions)
(Static Method)- Returns the raw string form of a template string (ES6).
String Properties
length
- Returns the length of a string.
This list covers the most common string functions and properties available in JavaScript, allowing for a variety of string manipulations.