Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome JavaScript developer console: Is it possible to call console.log() without a newline?

I'd like to use console.log() to log messages without appending a new line after each call to console.log(). Is this possible?

like image 225
MitchellSalad Avatar asked Mar 09 '12 01:03

MitchellSalad


People also ask

How do I print a console log without a new line?

stdout. write() method to print to console without trailing newline.

Does console log make a new line?

To create a multi line strings when printing to the JavaScript console, you need to add the new line character represented by the \n symbol. Alternatively, you can also add a new line break using Enter when you use the template literals syntax.

How do I make the console log in with different lines?

To display a console. log in multiple lines we need to break the line with \n console. log("Hello \n world!"); That will display it like this: Hello world!

Can I console log function in JavaScript?

log() with Examples. The console. log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.


2 Answers

No, it's not possible. You'll have to keep a string and concatenate if you want it all in one line, or put your output elsewhere (say, another window).

like image 61
Ry- Avatar answered Sep 20 '22 14:09

Ry-


In NodeJS you can use process.stdout.write and you can add '\n' if you want.

console.log(msg) is equivalent to process.stdout.write(msg + '\n').

like image 25
Pablo Yabo Avatar answered Sep 22 '22 14:09

Pablo Yabo