-1

Assuming we have the following Javascript Object

var t={name:"John",age:34,zip:"82900"}

If I use the following code to print all properties of that object:

for(var x in t){
console.log(t[x]);
}

I will get John, 34, 82900.Now my question is how to to print each propertie's name for example to print age,34 name,John that object might have more properties than i wrote above since the user can add its own properties inside that object

cssGEEK
  • 994
  • 2
  • 15
  • 38
  • possible duplicate of [Print content of JavaScript object?](http://stackoverflow.com/questions/1625208/print-content-of-javascript-object) – Blauharley Mar 28 '15 at 18:34

1 Answers1

1

var t = { name : "John", age : 34, zip : "82900" };

for(var x in t){
  console.log(x, t[x]);
}
blex
  • 24,941
  • 5
  • 39
  • 72