So I have this javascript object, and I want to loop through and print out each of it's property values.
Here's the code:
var names = {
            "firstName":"Billy",
            "lastName":"John",
            "age":30
        };
for(var a in names){
    console.log(names.a);
}
And it console.logs "undefined" 3 times.
But if I do something like this:
for(var a in names){
    console.log(names[a]);
}
It prints out Billy, John, 30.
If I console.log names.firstName outside the loop it works. And considering that during the first loop execution a is firstName, it should work.
Why does this happen? Thanks.
 
     
     
     
    