Difference between console.log and process.stdout.write in NodeJS

NodeJS can print a string to terminal using two ways. The well known console.log as in chrome and the lesser-known process.stdout.write way. Both have the same usage params. While you find console.log ends the line thats printed, the other does not.

So which is good to use?

The console.log is implemented in the NodeJS Core as nothing but a wrapper over process.stdout.write. So you may find something like this in the nodejs core lib:

Having said that, usage of both are equivalently efficient and you might actually prefer which one to use based on your personal comfort with which one you wanna type!

Leave a Reply