Store comma separate values into array
I want to store comma separate values into array. Later i want check it with different check.
var_str= name,address,s开发者_如何学JAVAtate,city // I want make array from this variable
How could i do this...
Thanks..
(Assuming that you have a string and want to convert it to an array)Split method on strings splits strings on a separator.
var str = "name,address,state,city";
var arr = str.split(',');
if you have such string:
var _str= 'name,address,state,city';
to get array from string use split javascript function:
var arr = _str.split(",");
If they're strings, jut give it array notation:
var str = [name,address,state,city];
in this array str[0]
would be name, etc. If they're not string's variables...I'm unsure what you're asking.
精彩评论