2

Given a string delimited by commas, how would I go about splitting it into an array in javascript?

1
  • +1 for using the split keyword in asking how to do it Commented Aug 26, 2010 at 16:37

3 Answers 3

5

var array = string.split(",") should do it where string is your string variable

Sign up to request clarification or add additional context in comments.

Comments

3

You can simply use the split() method on your string:

var myString = 'a,b,c';
var myArray = myString.split(',');

Comments

0

You use split. As in var myArray = "a,b,c".split(',');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.