JavaScript: How to use Console.log() to output object information

There are two ways of writing:

The first one:

console.log('my object:', obj);

The second type:

Write separately

console.log('my object:');

console.log(obj);

< p>If you use console.log('my object:'+obj); the error in the question will occur. This is because + is used to splice strings, and the structural syntax of the object is displayed at this time.