Tag: terminal

Pacharapol Withayasakpunt Pacharapol Withayasakpunt
Mon, February 24, 2020

If you have use JavaScript for some time, you should notice that pretty printing JSON in Node.js is as simple as JSON.stringify(obj, null, 2).

(Also, if you need multiline strings, there is js-yaml.)

  • But there is never coloring

An alternative is console.log, which in Node.js, it is not as interactive as web browsers with Chrome DevTools, and the depth in by default limited to 2.

  • How do you maximize depths?
    • Easy, use console.dir(obj, { depth: null }) -- console.dir