Contact List: Having trouble understanding


#1

How does the computer know prop is bill, steve, etc and that obj is the friends object without specifically referencing them in list? I can't seem to wrap my head around this.

var list = function(obj) {
var friends = {};
friends.bill = {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: ['One Microsoft Way','Redmond','WA','98052']
};
friends.steve = {
firstName: "Steve",
lastName: "Jobs",
number: "(408) 555-5555",
address: ['1 Infinite Loop','Cupertino','CA','95014']
};

var list = function(obj) {
for(var prop in obj) {
console.log(prop);
}
};


#3

Go ahead and ignore the "var list = function(obj) { " at the beginning.
So to clarify.Why doesnt it have to be something like this (which also works when running the code):

var list = function(friends) {
for(var firstName in friends) {
console.log(firstName);
}
};


#4

Hi hunterst89,

I have the same confusion as well. Did you manage to wrap your head around it at the end?