Javascript string to array by split() method
in this article, we will tell you how to convert string to an array by a split method using javascript. sometimes we need to string into a javascript array. we use to comma, space and pipe sign for the string to array.
Now, in the below following example we will take a string and convert it into a javascript array. here, in the below following example we use to space delimited. so you can follow the below example.
1 2 3 4 | <script type="text/javascript"> var fruit = "Apple Mango Watermelon Orange Cherry Grape"; console.log(fruit.split(' ')); </script> |
Please follow and like us: