There is not much else to say about the usage of js split. Let me give you an example directly below. >
The output result is
2
2
3
5
6
6
js split is to split a string into multiple strings with specific characters. You should You'll understand it at a glance.
The following is the official reference for the definition and usage of js split.
Definition and usage
The split() method is used to split a string into a string array.
Syntax
stringObject.split(separator,howmany)
Parameter Description
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 containing subexpressions, then the returned array includes strings matching those subexpressions (but not text matching the entire regular expression).