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

What are the JavaScript string methods?

coldplay.xixi
Release: 2020-06-30 14:18:55
Original
4789 people have browsed it

JavaScript string methods include: 1. indexOf method, finds whether a string contains a certain substring, and returns the position where the substring appears; 2. replace method, replaces certain characters in the string is a new character; 3. The split method will separate the string into an array according to the provided delimiter.

What are the JavaScript string methods?

JavaScript string methods are:

1. First, let’s introduce the commonly used indexOf method. This method mainly It is used to find whether a string contains a certain substring. It returns the position where this substring appears. If it appears at the beginning of the string, it returns 0. If it does not include the substring, it returns -1.

What are the JavaScript string methods?

#2. Another commonly used method is the replace method, which replaces certain characters in the string with new characters.

What are the JavaScript string methods?

#3. The split method is also one of the more commonly used methods. It will separate the string into an array according to the provided delimiter.

What are the JavaScript string methods?

4. The substring method can intercept part of the characters of the string. The parameters are the starting position and the stopping position. The code in the picture below starts from the fifth position and intercepts to the ninth position.

What are the JavaScript string methods?

#5. When you are dealing with English characters, the toLowerCase method is also commonly used, which is to change all characters to lowercase characters.

What are the JavaScript string methods?

6. Compared with toLowerCase, the toUpperCase method is to change all characters to uppercase characters.

What are the JavaScript string methods?

#7. There are other methods for strings, but they are relatively less commonly used. If you want to know more about them, you can check the JS help documentation.

What are the JavaScript string methods?

Related learning recommendations: javascript video tutorial

The above is the detailed content of What are the JavaScript string methods?. For more information, please follow other related articles on the PHP Chinese website!

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!