Basic console.log will not go through long and complex objects, and may decide to just print [Object] instead.
Two of the suitable ways to print the object with nested properties are exemplified below:
1.
util.inspect(object[, options])
const util = require('util'),
const obj = {} // some complex object
console.log(util.inspect(obj, {depth: null}));
//{ depth: null } instructs util.inspect to open everything until it gets to a circular reference
//There are other options also available, such as showHidden, colors, maxStringLength, maxArrayLength, sorted, etc.
//Documentation: https://nodejs.org/api/util.html#utilinspectobject-options
2.
JSON.stringify(value, replacer, space)
const obj = {}
console.log(JSON.stringify(obj, null, "\t"));
// "/t" would format the output with a tab in each line of property output
//Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
Work with our skilled Node developers to accelerate your project and boost its performance.
Hire Node.js Developers