[javascript] How to split comma separated string using JavaScript?

I want to split a comma separated string with JavaScript. How?

This question is related to javascript

The answer is


var partsOfStr = str.split(',');

split()


var array = string.split(',')

and good morning, too, since I have to type 30 chars ...


_x000D_
_x000D_
var result;_x000D_
result = "1,2,3".split(","); _x000D_
console.log(result);
_x000D_
_x000D_
_x000D_

More info on W3Schools describing the String Split function.


Use

YourCommaSeparatedString.split(',');