Skip to content

Instantly share code, notes, and snippets.

@nola
Last active January 3, 2016 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nola/8424740 to your computer and use it in GitHub Desktop.
Save nola/8424740 to your computer and use it in GitHub Desktop.
for loop: outputs property name and value
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