This article mainly introduces an example of the JavaScript string object split method. The split method is used to split strings into arrays. For more information, see
JavaScript split method
The split method is used to split a string into a string array and return the array. The syntax is as follows:
The Code is as follows:
Str_object.split (separator, limit)
Parameter description:
Parameters |
Description |
Str_object |
String (object) to be operated) |
Separator |
Required. Separator, string or regular expression, which is used to separate str_object |
Limit |
Optional. Specifies the maximum length of the returned array. If this parameter is set, no more substrings are returned than the array specified by this parameter. If this parameter is omitted, all compliant rules will be split. |
Tip: If you use an empty string ("") as a separator, each character in str_object is separated, as shown in the following example.
Split Method Instance
The Code is as follows: