I have a one-dimensional array of integer in JavaScript that I'd like to add data from comma separated string, Is there a simple way to do this?
e.g : var strVale = "130,235,342,124 ";
I have a one-dimensional array of integer in JavaScript that I'd like to add data from comma separated string, Is there a simple way to do this? e.g : |
|||||
|
You can use split()
|
|||||||||||||||||
|
You can use the String
Or, in one step, using Array
|
|||||
|
just you need to use couple of methods for this, that's it!
the output will be the array of numbers. |
||||
|
The split() method is used to split a string into an array of substrings, and returns the new array.
|
|||
|
You can split and convert like
Now you can use intValArray in you logic. |
|||
|