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

Detailed explanation of split method in javascript

hzc
Release: 2020-06-15 14:03:51
Original
3993 people have browsed it

Detailed explanation of split method in javascript

Detailed explanation of the split method in javascript:

The split() method is used to split a string into a string array.

Syntax

stringObject.split(separator,howmany)
Copy after login

Description of parameters

separator Required. A string or regular expression to split the stringObject from where specified by this parameter.​

howmany Optional. This parameter specifies the maximum length of the returned array. If this parameter is set, no more substrings will be returned than the array specified by this parameter. If this parameter is not set, the entire string will be split regardless of its length.

Return value

A string array. The array is created by splitting the string stringObject into substrings at the boundaries specified by separator . The strings in the returned array do not include the separator itself.

However, if separator is a regular expression that contains subexpressions, the returned array includes the strings that match those subexpressions (but not the text that matches the entire regular expression).

Tips and Notes

Note: If an empty string ("") is used as a separator, each character in the stringObject will be separated.

Recommended tutorial: "JS Tutorial"

The above is the detailed content of Detailed explanation of split method in javascript. 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!