How do I separate a comma delimited variable into multiple variables?

This is probably very elementary, but I'm still learning. I've imported a record from an XML file and have the result : "a,b,c,d,e,f,g,h"

I would like to end up with 8 separate variables, one for each comma delimited value. What is the shortest way to code this using javascript?

Answers


if you .split() the list, you'll end up with a single array with 'n' number of elements. Not -exactly- 8 separate variables, but 8 elements that can be accessed individually.

var myList = "a,b,c,d,e,f,g,h";
var myArray = myList.split( ',' );

alert( myArray[ 4 ] );

Need Your Help

Null pointer in putExtras

android android-intent nullpointerexception

I have some trouble with putExtras to an intent. Could you please review my code?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.