Home »
JavaScript
JavaScript String Object Methods
The String is an object in JavaScript which is used to store a sequence of characters.
In JavaScript, the String object contains various methods which are used for string-related operations.
JavaScript String Object Methods: This section contains various String object methods with examples.
List of JavaScript String Object Methods
| Method |
Description |
| toLowerCase() |
It converts all alphabets in lowercase and returns the new string with lowercase alphabets |
| toUpperCase() |
It converts all alphabets in uppercase and returns the new string with uppercase alphabets. |
| startsWith() |
It checks whether a string starts with a specified substring or not. |
| endsWith() |
It checks whether a string ends with a specified substring or not. |
| charAt() |
It returns the character of specified index from the string. |
| charCodeAt() |
It returns the Unicode of character at the specified index in the string. |
| fromCharCode() |
It returns the character from the given Unicode(s). |
| substr() |
It extracts a part of the string (substring) from the given string. |
| replace() |
It replaces a given part of the string in another given string and returns new string. |
| indexOf() |
It checks whether a substring exists in the given string or not. |
| lastIndexOf() |
It checks whether a substring exists in the given string or not. |
| search() |
It checks whether a substring exists in the given string or not. |
| concat() |
It concatenates (joins) two or more strings and returns a new joined string. |
| includes() |
It checks if the character is present in the string or not. |
| repeat() |
It generates a string by repeating the calling string n number of times. |
| normalize() |
It finds the Unicode normalized form of the string passed as a parameter to the function. |
| slice() |
It returns a part of the string. |
| localeCompare() |
It compares two strings. |
| substring() |
It returns a part of the string. |
| valueOf() |
It returns the value of the given string. |
| indexOf() Vs. search() |
Learn the differences between indexOf() and search() methods in JavaScript. |
Advertisement
Advertisement