Difference between process.stdout.write and console.log in Node.js
Both process.stdout.write and console.log in NodeJS have basic functionality to display messages on the console. Basically console.log implement process.stdout.write while process.stdout.write is a buffer/stream that will directly output in our console.
Difference between process.stdout.write and console.log in Node.js are:
|1||It continuously prints the information as the data being retrieved and doesn’t add a new line.||It prints the information that was obtained at the point of retrieval and adds a new line.|
|2||Using process.stdout for a variable that shows an object.||Using console.log for a variable shows a lot of unreadable characters.|
|4||If we don’t put the break line at the end we will get a weird character after our string.||We don’t need the break line here because it was already formatted and also that weird character did disappear|
|5||It can be useful for printing patterns as it does not add a new line.||It is used when we want our result to be printed in a new line.|
We can not write more than one string. For example:
We can write more than one string. For example:
We can not make associations. For example:
We can make associations. For example:
Example: Below example is to show to use of process.stdout.write
Example: Below example is to show to use of console.log
Hello World !!!