Is there a way to get new lines in console.log when printing multiple objects?
Suppose we have console.log(a,b,c)
where a
, b
, and c
are objects. Is there a way to get a line break between the objects?
I tried console.log(a,'\n',b,'\n',c)
but that does not work in node
Another way would be a simple:
I have no idea why this works in node but the following seems to do the trick:
compliments of theBlueFish
An alternative is creating your own logger along with the original logger from JS.
If you want to avoid any clash with the original logger from JS
Without adding white space at start of new line:-
console.log("one\ntwo");
output:-
one two
This will add white space at start of new line:-
console.log("one","\n",two");
output:-
one two
You need to use
\n
inside theconsole.log
like this:Add
\n
(newline) between them: