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

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

Method description:

This method is the same as console.error(). As you can see from the source code, console.error is actually a direct call to console.warn

Grammar:


console.warn([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.error('count: %d', count);

Source:


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


Related articles: