In Node.js, if you want to see the full content of an object when using console.log()
, you can use util.inspect()
to achieve this. The util.inspect()
function provides a way to inspect and format objects for debugging purposes.
Here's an example of how you can use util.inspect()
to display the full content of an object in the Node.js console:
javascript
const util = require('util');
const myObject = {
name: 'John',
age: 30,
city: 'New York'
};
console.log(util.inspect(myObject, { showHidden: false, depth: null }));
In this example, util.inspect()
is used to display the content of the myObject
object. The showHidden
option is set to false
to not show hidden properties, and the depth
option is set to null
to allow the full object hierarchy to be displayed.
When you run this code, the output in the console will show the full content of the object, including all properties and nested objects, without using the [Object]
placeholder.
Comments
Post a Comment