When concatenating strings, console.log
isn't great. console.log("thing: " + thing);
prints thing: [object Object]
.
But if you leave out the string concatenation, printing single object with no string concatenation usually gives good output.
For instance, this code:
let x = {a: 1, b: 2, c: {d: 3, e: 4}};
console.log(x);
Produces this debug in Firefox:

And that can be expanded into a form pretty similar to rust's dbg!()
:

And in node, it produces this:
> let x = {a: 1, b: 2, c: {d: 3, e: 4}};
undefined
> console.log(x);
{ a: 1, b: 2, c: { d: 3, e: 4 } }
Node also automatically expands to a horizontal layout when necessary:
> console.log({one_long_identifier_word: 4, two_long_identifier_identifier_words: 5, three_long_identifier_identifier_identifier_words: 7})
{
one_long_identifier_word: 4,
two_long_identifier_identifier_words: 5,
three_long_identifier_identifier_identifier_words: 7
}
All in all, I think it's very similar to the functionality present in dbg!()
and other Rust debug printing tools.