Learn about JavaScript strings and how to work with them.
|
Template Literals Handling Strings with Template Literals |
Learn how to use JavaScript template literals (backticks) for string manipulation, including multiline strings, variable interpolation, expressions, and dynamic URL creation with practical examples. |
|---|---|
|
trim() Leading and Trailing Whitespace |
The trim() function removes whitespace from both ends of a given string and returns a new string without modifying the original string. |
|
toLowerCase() Convert a String to Lowercase |
The toLowerCase() function returns the given string converted to lowercase. Since it only returns the converted string, the original string remains unchanged. |
|
toUpperCase() Convert a String to Uppercase |
The toUpperCase() function returns the given string converted to uppercase. Since it only returns the converted string, the original string remains unchanged. |
|
includes() Checking if a String Contains a Substring |
The includes() function for strings checks whether a given string contains a specified substring and returns true if it does, or false otherwise. |
|
indexOf() Find First Substring Index |
The indexOf() function for strings returns the index of the first occurrence of the specified substring. If the specified substring is not found, it returns -1. |
|
search() Searching for Matching Strings Using Regexes |
The search() function for strings searches for a match between a regular expression and a string, returning the index (integer) of the first match. |
|
replace() Replacing Text in a String |
The replace() function for strings returns a new string where one or more occurrences of a specific substring or a regular expression pattern are replaced by a specified replacement. |
|
slice() Slice a String by Index Range |
The slice() function for strings slices a string by an index range and returns a new string without modifying the original string. |
|
split() Splitting a String and Returning an Array |
The split() function splits a given string based on a specified delimiter or a regular expression and returns a new array. |
|
substring() Extract a Substring |
The substring() function extracts a specific portion of a string. It returns a new string from the specified start index up to, but not including, the end index. |
|
match() Finding Matches with Regular Expressions |
The match() function for strings uses a regular expression to find parts of a given string that match and returns the result. |