ajsie ajsie - 1 year ago 214
Node.js Question

Difference between "process.stdout.write" and "console.log" in node.js?

What is the difference between "process.stdout.write" and "console.log" in node.js?

EDIT: Using console.log for a variable showed a lot of unreadable characters while using process.stdout.write showed an object.

Why is that?

Answer Source

console.log() calls process.stdout.write with formatted output. See format() in console.js for the implementation.

Currently (v0.10.ish):

Console.prototype.log = function() {
  this._stdout.write(util.format.apply(this, arguments) + '\n');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download