var string = 'a,b,c,d';
var array = [];
As we can see above I have one string values with separator*(,)*. I want to split these values and wants to push in the array. At last I want to read my array by using for loop. Please suggest.
Use the String.split()
var array = string.split(',');
var string = 'a,b,c,d',
strx = string.split(',');
array = [];
array = array.concat(strx);
// ["a","b","c","d"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With