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

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

Possible Duplicate:
How do I split this string with javascript?

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

Solutions/Answers:

Solution 1:

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

split()

Solution 2:

var array = string.split(',')

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

Solution 3:

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

More info on W3Schools describing the String Split function.

Solution 4:

Use

YourCommaSeparatedString.split(',');

Related:  How to copy text to the client's clipboard using jQuery? [duplicate]