When I write something like:
console.log("data", data);
where data is an object, it'll print "data [some form of the object]" where [some form of the object] is typically a collapsed object with expand arrows that I can click to view the object's elements.
However, this can become painful when the preceding text line is long and there's a lot of output... and I'd rather have that object start on the next line, which makes me either add another console.log just for that object, or add a \n to the preceding line string.
Since console.log('whatever', whatever) appends a space to 'whatever' when a comma follows it, I'd like some way to specify 'use a newline in this case, or for objects following the comma', but I'm not seeing how to do that.
Is this possible in any way?
You can use console.dir and the document for it here: https://developer.mozilla.org/en-US/docs/Web/API/console/dir
You need another function that wrapps the console.log(),
fancyLog = function(...args){
args.forEach( arg=>{
console.log( arg );
} );
}
this wrapper function will get your task done.
The short answer is no, what you are asking doesn't exist just like that.
You can hack it by doing something like:
console.log(`whatever\n${JSON.stringify(whatever, null, 2)}`);
Which will print the object in json in the next line. Or if you don't need that, just:
console.log(`whatever\n${whatever}`);
But it's debatable how much work it really saved from just adding two console.logs.
Your final option is to use console.dir or console.table following that console.log, but again it doesn't save you from having to place two lines there.