Skip to content

Instantly share code, notes, and snippets.

@honux77
Created November 15, 2014 01:39
Show Gist options
  • Select an option

  • Save honux77/523bee70b30f81b63f39 to your computer and use it in GitHub Desktop.

Select an option

Save honux77/523bee70b30f81b63f39 to your computer and use it in GitHub Desktop.
object dictionary
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);
}
};
var search = function(name) {
for(var prop in friends) {
if(friends[prop].firstName === name) {
console.log(friends[prop]);
return friends[prop];
}
}
};
list(friends);
search("Steve");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment