|separator||The separator argument is used to specify the character, or the regular expression, to use for splitting the string.|
The limit argument is the upper limit on the number of splits found in the given string.
The split() method returns an array of strings formed at each position where the separator occurs.
Let’s define a string containing comma-separated values and convert it into an array using the split() method.
let str = "Tokyo,Nairobi,Berlin,Oslo,Moscow" let arr = str.split(",") console.log(arr)
['Tokyo', 'Nairobi', 'Berlin', 'Oslo', 'Moscow']
You can see in the output that the CSV string is converted into an array.
That’s it for this tutorial.