/ Published in: JavaScript
What this does is prints out every property within the object, rather than having to write the code for printing out each specific property.
In English, what is the code doing? It says: Assign the first property of the dog object to the variable property. Run the code (here, it is to print property to console). Then assign the second property of the dog object to the variable property. Again, run the code in the curly brackets. Keep repeating this until all the properties of the dog have been assigned to property.
In English, what is the code doing? It says: Assign the first property of the dog object to the variable property. Run the code (here, it is to print property to console). Then assign the second property of the dog object to the variable property. Again, run the code in the curly brackets. Keep repeating this until all the properties of the dog have been assigned to property.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var nyc = { fullName: "New York City", mayor: "Michael Bloomberg", population: 8000000, boroughs: 5 }; for (var property in nyc){ console.log(property); }