Split a string
<html> <body> <script language="javascript"> function function1(){ var myString = 'www. java2s .com'; var myArray = myString.split(' '); alert(myArray.length); } </script> <button onclick="function1();">String split</button> </body> </html>