The split method breaks the specified string into an array, based on the specified delimiter. To split an array at each and every character, use the empty string "" for the delimiter, as shown in the second example below.
Code:
<script type="text/javascript"> //<![CDATA[
myString = "orange-apple-banana-pear"; myArray = myString.split("-"); document.write("myString : ", myString, "<br><br>"); for (i=0; i<myArray.length; i++) { document.write("myArray[", i, "] : ", myArray[i], "<br>"); } //]]> </script>
Output: