Q:

Why does an array with a variable name of 'names' turn into a string when i put in 'name'?

I declared an array called names. I used a while loop to go over each name and log them into the console.
Then, I accidentally mistyped 'names' into 'name'. Normally, that gives out a reference error, but what it logged are the different characters of the first name. And I checked the developer tools and looked for the variable "name" because I did not define the variable **"name"
 var names = ['John', 'Jane', 'Mary', 'Mark', 'Bob'];

 var i = 0;
 while (i < names.length) {
       console.log(name[i]);
       i++;
 }

What It Printed Out In The Console
    J
    o
    h
    n
    ,

Then I looked for  the variable "name" cos I did not declare it and this came out
    names
    "John,Jane,Mary,Mark,Bob"

What is the reason behind this?

A:

You missed an s for name in console.log(name[i]);. 
Change it to console.log(names[i]);

A:

First of all i added a simple console.log() to see what name is. In this case we did not define the variable name, so it is the default shorthand variable for  window.name. This explains the behaviour, that there is no reference error. Lets take a closer look to it:

var names = ['John', 'Jane', 'Mary', 'Mark', 'Bob'];

var i = 0;
console.log(name);
var charactersThatWillBeShown = name.substr(0, names.length);
console.log(charactersThatWillBeShown);
var loggedCharacters = "";
while (i < names.length) {
   loggedCharacters += name[i];
   console.log(name[i]);
   i++;
}
console.log(loggedCharacters);
console.log(charactersThatWillBeShown == loggedCharacters);
.as-console-wrapper { 
  min-height: 100%;
}

