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.js.
The newline character is \n in JavaScript and many other languages. All you need to do is add \n character whenever you require a line break to add a new line to a string.
log() function from console class of Node. js is used to display the messages on the console. It prints to stdout with newline. Parameter: This function contains multiple parameters which are to be printed.
js provides a console module which provides tons of very useful ways to interact with the command line. It is basically the same as the console object you find in the browser. The most basic and most used method is console. log() , which prints the string you pass to it to the console.
Add \n
(newline) between them:
console.log({ a: 1 }, '\n', { b: 3 }, '\n', { c: 3 })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With