[object Object] appears in the log when there is an object with keys and values. You can access the properties of an object with dotted notation (.), For example,
objectName.propertyName
If ProperyName is another object, it will still return [Object], and therefore you need to look for another property in this. Properties may also contain methods (functions). If you want to get a string version of an object to compare them, for example, use
JSON.stringify(objectName);
When using console.log with a node, when you have a deeply nested object, you will not be able to view the contents of the nested object. In this case you can use:
console.log(util.inspect(objectName, false, null));
To view the entire object. Although you need to specify util in the file.
Maybe you have something like:
const myObject = { hello: 'world' }; console.log('My object: '+myObject);
The problem is that it converts myObject to a string in the console, for example using myObject.toString() . In this case, you can simplify for yourself and separate it as follows:
const myObject = { hello: 'world' }; console.log('My object:', myObject);
And now the console can interpret myObject and display it beautifully.
source share