var_dump() for Javascript

PHP, for example, has var_dump() and print_r() to facilitate quick variable dumps to log files, etc. For Javascript, one can use console.log() in combination with JSON.stringify() to achieve something similar.   console.log( JSON.stringify(object) ); It’s also possible to “pretty-print” the output like so:   console.log( JSON.stringify(object, null, 2) ); For more information …

More