Created
October 21, 2014 00:58
-
-
Save JacobHsu/20c7743b55d077fbd09f to your computer and use it in GitHub Desktop.
#JS - Introduction to Objects Loop the loop
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
| // Our Person constructor | |
| function Person (name, age) { | |
| this.name = name; | |
| this.age = age; | |
| } | |
| // Now we can make an array of people | |
| var family = new Array(); | |
| family[0] = new Person("alice", 40); | |
| family[1] = new Person("bob", 42); | |
| family[2] = new Person("michelle", 8); | |
| family[3] = new Person("timmy", 6); | |
| // loop through our new array | |
| for (var n in family){ | |
| console.log(family[n].name); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment