Mastering JavaScript
37 Essential JavaScript String
Methods Every Developer Should Know
at()
Returns the character at the specified
index in a string.
charAt()
Returns the character at the specified
index in a string.
charCodeAt()
Returns the Unicode value of the
character at the specified index in a
string.
codePointAt()
Returns the Unicode code point value
of the character at the specified index
in a string.
concat()
Combines multiple strings and
returns a new string.
endsWith()
Checks if a string ends with the
specified substring and returns true
or false.
fromCharCode()
Returns a string created from a
sequence of Unicode values (codes).
fromCodePoint()
Returns a string created from a
sequence of Unicode code points.
includes()
Checks if a string contains the
specified substring and returns true
or false.
indexOf()
Returns the index of the first
occurrence of a specified value
within a string.
lastIndexOf()
Returns the index of the last
occurrence of a specified value
within a string.
isWellFormed()
Checks if a string is well-formed
Unicode and returns true or false.
localeCompare()
Compares two strings in the current
locale and returns -1, 0, or 1,
indicating their relative order.
match()
Searches a string for a match against
a regular expression and returns an
array of matches.
matchAll()
Returns an iterator of all matched
substrings against a regular
expression.
normalize()
Returns the Unicode Normalization
Form of a string (e.g., NFC, NFD,
NFKC, NFKD).
padStart()
Pads the current string with another
string until it reaches the specified
length.
padEnd()
Pads the current string with another
string until it reaches the specified
length.
raw()
Returns the raw string representation
of a template literal, ignoring escape
sequences.
repeat()
Returns a new string containing the
original string repeated the specified
number of times.
replace()
Returns a new string with some or all
matches of a pattern replaced by a
replacement string.
replaceAll()
Returns a new string with all matches
of a pattern replaced by a
replacement string.
search()
Searches a string for a specified
pattern and returns the index of the
first match found.
slice()
Extracts a section of a string and
returns a new string.
split()
Splits a string into an array of
substrings based on a specified
separator.
startsWith()
Checks if a string starts with the
specified substring and returns true
or false.
substring()
Extracts a section of a string and
returns a new string.
toLocaleLowerCase()
Converts the string to lowercase
according to any locale-specific case
mappings.
toLocaleUpperCase()
Converts the string to uppercase
according to any locale-specific case
mappings.
toLowerCase()
Converts the string to lowercase.
toUpperCase()
Converts the string to uppercase.
toString()
Returns a string representation of an
object.
toWellFormed()
Returns a new string that represents
the string as a well-formed Unicode
string.
trim()
Removes whitespace from both ends
of a string.
trimStart()
Removes whitespace from the start
of a string.
trimEnd()
Removes whitespace from the end of
a string.
valueOf()
Returns the primitive value of a string
object.
Thank you for exploring this
comprehensive guide on JavaScript
string methods. I hope it has been
a valuable resource for enhancing
your coding skills.
Happy coding and stay curious!