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

Summary of common methods of JavaScript String objects_javascript skills

PHP中文网
Release: 2016-05-16 15:03:18
Original
1280 people have browsed it

Strings are immutable. The string method does not change the content of the original string, but returns a new string.

charAt(): Returns the character at the specified position.

concat(): Concatenates two string literals and returns a new string.

indexOf():indexOf() method returns the position of the first occurrence of the specified value in the string object.

match(): Use regular expressions to compare with strings.

replace(): is used to directly compare the regular expression and the string, and then replace the matched substring with the new substring.

slice(): Extract a string area and return a new string.

split(): Split the string object into a string array by splitting the string into strings.

substr(): Returns the substring starting from the specified position to the specified length in the string.

substring(): Returns the substring between two indices of the string (or to the end of the string).

Unlike the slice() and substr() methods, substring() does not accept negative arguments.

trim(): Remove blank characters at both ends of a string.

The above is a summary of common methods of JavaScript String objects_javascript skills. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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