最近自学JAVA,遇到了一个小小问题
var friends={bill:{
firstName:"Bill",
lastName:"jay",
number:"4454545464",
address:['One Microsoft Way','Redmond','WA','98052']
},
steve:{
firstName:"Steve",
lastName:"fdsa",
number:"1212111",
address:['One Microsoft Way','Redmond','WA','98052']
}
};
var list = function() {
for( var keys in friends ){
console.log(keys);
}
};
var search = function(name) {
for(var look in friends) {
if(friends[look].firstName === name) {
console.log(friends[look]);
return friends[look];
}
}
};
如上,谁能帮忙解释一下那个 search函数的原理呀?我看的英文,不大理解。谢谢!