In Ruby, you can do foo.inspect
and it outputs something sane for any object pretty much regardless of type.
How do I achieve the same thing in JavaScript?
JSON.stringify(foo)
works pretty well.
This is possibly not the entirely general answer you're hoping for, since this introduces third-party dependencies into you application. However, they're worth mentioning:
Object.inspect
(link)jquery-inspect
(link) pluginIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With