What is the JavaScript equivalent of var_dump or print_r in PHP?

Adriana picture Adriana · Mar 2, 2009 · Viewed 428k times · Source

I would like to see the structure of object in JavaScript (for debugging). Is there anything similar to var_dump in PHP?

Answer

Paolo Bergantino picture Paolo Bergantino · Mar 2, 2009

Most modern browsers have a console in their developer tools, useful for this sort of debugging.

console.log(myvar);

Then you will get a nicely mapped out interface of the object/whatever in the console.

Check out the console documentation for more details.