JavaScript split() Method

  1. <script type=“text/javascript”>
  2.  
  3. var str=“How are you doing today?”;
  4.  
  5. document.write(str.split() + “<br />”);
  6. document.write(str.split(“ ”) + “<br />”);
  7. document.write(str.split(“”) + “<br />”);
  8. document.write(str.split(“ ”,3));
  9.  
  10. </script>

The output of the code above will be:

How are you doing today?
How,are,you,doing,today?
H,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,?
How,are,you

Leave a Reply