+ 1

Whenever I try to print an object i get "[Object Object]".

Is there some way to print the entire object along with the {},:and ; together as a string such that it shows the entire object as well as the objects contained in it.

19th Aug 2020, 10:05 AM
Deven
Deven - avatar
2 Answers
+ 8
Yes you can Method 1 var person={ name:"sayed", age:17 } document.write(JSON.stringify(person)); Method 2 for(x in person){ document.write(x+":"+person[x]); }
19th Aug 2020, 10:11 AM
TOLUENE
TOLUENE - avatar
+ 1
Try using node js or loop over the keys and their values if you know the structure of object
19th Aug 2020, 10:24 AM
Abhay
Abhay - avatar