Essential JavaScript string method you should know
In this article, I will summarize some JavaScript string method you should know.
A string can be anything inside double or single quotes.
Some of important string method for beginner:
- charAt(): The charAt() method returns the new string at the specified index in a string.
2. concat():The concat() method is used to join two or more strings.
3. includes(): The includes() method is case sensitive. It finds whether a string include the string of a specified string. It return Boolean true or false.
4. endsWith():The endsWith() method is case sensitive. It finds whether a string end with the string of a specified string. It return Boolean true or false.
5. startsWith():The startsWith() method is case sensitive. It finds whether a string start with the string of a specified string. It return Boolean true or false.
6. toLowerCase(): The toLowerCase() method convert the a string value to lower case.
7. toUppercase():The toUpperCase() method convert the a string value to upper case.
8. indexOf(): The indexOf() method is case sensitive. The indexOf() method return the index of first occurrence of specific value of string.
9. lastIndexOf(): The lastIndexOf() method is case sensitive. The lastIndexOf() method return the index of last occurrence of specific value of string.
10. trim(): the trim() method delete the whitespace from both end of string.