Sometimes, we want to print to the console without a trailing newline with Node.js.
In this article, we’ll look at how to print to the console without a trailing newline with Node.js.
How to print to the console without a trailing newline with Node.js?
To print to the console without a trailing newline with Node.js, we can use the process.stdout.write
method.
For instance, we write
process.stdout.write(`Downloading ${data.length} bytesr`);
to print Downloading ${data.length} bytesr
.
The r
character lets us overwrite the last line that was printed with new text that we print with process.stdout.write
.
Conclusion
To print to the console without a trailing newline with Node.js, we can use the process.stdout.write
method.