Use instructions for the console.log method in node.js

  • 2020-03-30 04:33:21
  • OfStack

Method description:

Prints a character to the standard output stream and ends with a newline.

Grammar:


console.log([data], [...])

Receiving parameters:

Console.log takes several parameters, and if there is only one parameter, it outputs the string form of that parameter.

If there are more than one argument, the output is in a format similar to the C printf() command.

If there are no arguments, only a newline character is printed.

Example:


var count = 1234;
console.log('count: %d', count);
//Output & NBSP; Count: 1234; < br / > console.log('Hello world');
//Output & NBSP; Hello world. < br / > console.log('count: %d');
//Output & NBSP; Count: % d; < br / >

Source:


Console.prototype.log = function() {
  this._stdout.write(util.format.apply(this, arguments) + 'n');
};


Related articles: