Home >Web Front-end >JS Tutorial >Summary of common methods of JavaScript String objects_javascript skills
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)!