Following is some codes and output from the Chrome Developers\' Console
Case 1:
var myarr = document.location.hostname.split(\".\");
name in global scope is an empty string, so in the latter case you get the array returned by split transformed into a string "www,hostname,com". So name[0] gets you the first letter only.