This is recopied from the pink section on the previous page. This did not make any sense to me whatsoever. No matter how I looked at it, I just couldn't get it...

Omitting a Separator

If the separator -- content in the "( )" part -- is omitted, the returned array will contain the whole string in index [0]. If the separator is "", the returned array will be an array of single characters:
   var txt = "Hello";  <== String
   txt.split( );  <== Split in characters: This returns "Hello" horizontally
   txt.split("");  <== Split in characters: This returns "Hello" vertically, when used as shown below:

HTML file: Displayed by browser:
<body>
<p id="demo"></p>
<script>
    var str = "Hello";
    var arr = str.split("");
    var text = "";
    var i;
    for (i = 0; i < arr.length; i++) {
        text += arr[i] + "<br />"
}
    document.getElementById("demo").innerHTML = text;
</script>
</body>

Still no clue what's going on...

BackTable of ContentsNext