How do I display the content of a JavaScript object in a string format like when we alert
a variable?
The same formatted way I want to display an object.
How do I display the content of a JavaScript object in a string format like when we alert
a variable?
The same formatted way I want to display an object.
try this :
This will print the stringify version of object. So instead of
[object]
as an output you will get the content of object.Well, Firefox (thanks to @Bojangles for detailed information) has
Object.toSource()
method which prints objects as JSON andfunction(){}
.That's enough for most debugging purposes, I guess.
If you would like to see data in tabular format you can use
Table can be sorted if you click on the table column.
You can also select what columns to show:
You can find more information about console.table here
console.dir(object)
:Note that the
console.dir()
feature is non-standard. See MDN Web Docsi used pagewil's print method, and it worked very nicely.
here is my slightly extended version with (sloppy) indents and distinct prop/ob delimiters: