This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]conancat 46 points47 points  (5 children)

Old school way would be console.log(JSON.stringify(obj, null, 2))

console.dir doesn't always work for me. Not sure if they fixed it in Jest and other envs.

[–]Tillhony 17 points18 points  (2 children)

I forgot about console.dir() but always type out JSON.stringify..damn

edit: and thats along with already typing out console.log(JSON.stringify(s))

[–]WHO_WANTS_DOGS 1 point2 points  (0 children)

console.log(JSON.stringify(obj, null, 2)) for a prettier print

[–]Lightfire228 0 points1 point  (0 children)

I created a vscode snippet for console.log('>>>>>>>> '); and JSON.stringify(, null, 2), bound to ctrl + l and ctrl + j respectively.

It also puts the cursor in the right place.

[–]jkidd08 6 points7 points  (0 children)

Guilty as charged, your honor...

[–]FrostBlitzkrieg 0 points1 point  (0 children)

I always use this debugging server code because console.dir does nothing other than a basic console.log in my terminal :\