print properties and values of an object at the same time-Javascript -
assuming have following javascript object
var t={name:"john",age:34,zip:"82900"}
if use following code print properties of object:
for(var x in t){ console.log(t[x]); }
i john, 34, 82900.now question how to print each propertie's name example print age,34 name,john object might have more properties wrote above since user can add own properties inside object
var t = { name : "john", age : 34, zip : "82900" }; for(var x in t){ console.log(x, t[x]); }
Comments
Post a Comment