javascript - Convert comma separated string to array -


I have a comma separated string that I want to convert to an array so that I can loop through it .

Is anything inherent to doing this?

For example, I have this string

  var str = "January, February, March, April, May, June, July, August, September, October, November , December";  

Now it is to divide it by comma and store in the array object

< Previous> var array = string.split (',');

, potentially potentially unpredictable behaviors of the range parameter (sign: "a, b, c" .split ("," , 2) comes out of ["a", "b"] , not ["a", "b, c"] .) < / P>


Comments