Home > Web Front-end > JS Tutorial > body text

Application summary of common string processing methods in JS_javascript skills

WBOY
Release: 2016-05-16 16:47:17
Original
1298 people have browsed it

1.The indexOf() method, searches the string position from front to back, is case-sensitive, and starts counting from 0. In the same way, the lastIndexOf() method works from back to front. The output results of the two methods are the same for the same search conditions

For example:

Copy Code The code is as follows:



2.length is accessed in the form of "XXX.length" because it is not found It is a method of string object
Copy code The code is as follows:



3.substr() method, used for string interception, one required parameter, one optional parameter, counting from 0
Copy code The code is as follows:



4. The charAt() method is used to return the character at the specified position, counting from 0
Copy code The code is as follows:



5.split() method, used to split a string into a string array
Copy code The code is as follows:


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!