Return to Kroll Design home page

JavaScript Tutorials

 
« Return

split method for strings

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:



 
« Return


©2012 Kroll Design    info@KrollDesign.net    781.910.3694
Last modified: 12/31/1969 7:00 PM