[JavaScript] How to convert comma separated string into an array?
I want to convert a comma separated string into an array, how to do that in Javascript?
1 Answer
4 years ago by Jahaan
split() method is used to convert a string in to an array.
Usage:
string.split(separator, limit)
Example:
let colors = 'red,blue,green,yellow';
console.log(colors.split(','));
4 years ago by Meera