Last active
January 3, 2016 06:48
-
-
Save nola/8424740 to your computer and use it in GitHub Desktop.
for loop: outputs property name and value
This file contains 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 nyc = { | |
fullName: "New York City", | |
mayor: "Michael Bloomberg", | |
population: 8000000, | |
boroughs: 5 | |
}; | |
//This loop will output ALL the properties of this object | |
for(var i in nyc){ | |
//console.log(i); //Notice we are printing out PROPERTIES not the properties VALUES | |
console.log(i + ": " +nyc[i]); //This will print out all the objects VALUES | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment