Home >Web Front-end >JS Tutorial >A brief discussion on common methods of String objects in JavaScript_javascript skills

A brief discussion on common methods of String objects in JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:13:031149browse

The methods provided by the String object are used to process strings and characters.
Some commonly used methods:

charAt(index): Returns the character at index in the string.
indexOf(searchValue,[fromIndex]): This method looks for the first occurrence of searchValue in the string. If fromIndex is given, the search starts from this position within the string. When searchValue is found, the position of the first character of the string is returned.
lastIndexOf(searchValue,[fromIndex]): Searches searchValue forward from the end of the string and reports the first instance found.
substring(indexA,indexB): Get the substring from indexA to indexB
toLowerCase(): Convert all characters in the string to lowercase
toUpperCaser(): Convert all characters in the string to uppercase

Have you guys understood the usage of String objects? I hope you like this article.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn