Take the 2-minute tour ×  I am using jQuery  I have got below in
my string  str = "Michael,Singh,34534DFSD3453DS"  Now I want my
result in three variables.  str1 = "Michael" str2 = "Singh" str3
= "34534DFSD3453DS"  Please suggest!   share|improve this
question No need for "Please suggest!" and the like. If people
are reading your question, their reason for doing so is to reply
and help you. –  T.J. Crowder Dec 16 '10 at 9:12  5 Answers 5
up vote 5 down vote accepted  var strs = str.split(',') is your
best bit. This will create an array for you so  strs[0] =
"Michael" strs[1] = "Singh" strs[2] = "34534DFSD3453DS"
However, it is possible to get exactly what you want by adding
new items to the window object. For this I use the $.each method
of jQuery. It's not necessary (you can just use a for) but I
just think it's pretty :). I don't recommend it, but it does
show how you can create new variables 'on the fly'.  var str =
"Michael,Singh,34534DFSD3453DS";  $.each(str.split(','),
function(i,item){    window['str