Created
November 15, 2014 01:39
-
-
Save honux77/523bee70b30f81b63f39 to your computer and use it in GitHub Desktop.
object dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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