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,
An alternative is creating your own logger along with the original logger from JS.
var originalLogger = console.log;
console.log = function() {
for (var o of arguments) originalLogger(o);
}
console.log({ a: 1 }, { b: 3 }, { c: 3 })
If you want to avoid any clash with the original logger from JS
console.ownlog = function() {
for (var o of arguments) console.log(o);
}
console.ownlog({ a: 1 }, { b: 3 }, { c: 3 })
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
Another way would be a simple:
console.log(a);
console.log(b);
console.log(c);
Add \n (newline) between them:
console.log({ a: 1 }, '\n', { b: 3 }, '\n', { c: 3 })
You need to use \n inside the console.log like this:
console.log('one','\n','two');
You can use template literal
console.log(`a is line 1
b is line 2
c is line 3`)
to activate template literal you need to click on character to the left of number 1, on my keyboard - Microsoft Wired 600
DO NOT CONFUSE: ' symbol, that is same as shift + @ on my keyboard with `
' and " will create strings and ` will create template literals