JavaScript strings are used for storing characters. it is written under quotes. strings written under single or double quotes works same. there is no difference between the two.
String Methods :
JavaScript provides several string methods to manipulate the string. here are some examples of these methods.
1. Length:
length is used to check the length of specific string.
2. CharAt():
CharAt method is used to retrieve the character at specific index
3. Substring():
This method returns a substring based on start and end indices.
4.touppercase() and tolowercase():
touppercase() method is used to convert the string into uppercase
tolowercase() method is used to convert string into lowercase.
5.indexof() and lastindexof():
indexof() method return the index number of character if specific alphabet occur twice in string then it will give index for first occurrence.
lastindexof() method return the index number of last occurrence of character.
6.Replace():
This method is used to replace the particular word with another word in string .
7.Concatenation
Developer can concatenate two strings using "+" operator
- includes()
- repeat()
- trim()
- charcodeAt()
- match()
Comments
Post a Comment