How does js convert strings to arrays?
The function of js string to array conversion is “split()”, and its usage is as follows
string.split( separator,limit)
Parameter value
parameter | description |
separator | Optional. A string or regular expression to split the string Object from where specified by this parameter. |
limit | 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. |
First create a new index.html file and add the following code:
Then run the index.html file in the browser to view the console
Related reference: JS Tutorial
The above is the detailed content of how js converts strings into arrays. For more, please pay attention to other related articles on 1024programmer.com!