Here we created an object called "person" with three properties we are going to use the for/in loop to display the property names as well as the values of those properties
var person = new Object();
person.name = "Tech Junkie";
person.occupation = "Blogger";
person.location = "Mars";
for(var p in person)
console.log(p + ": " + person[p]);
Here is the output:
No comments:
Post a Comment