Tuesday, 2 October 2018

node.js: console.error([data][, ...args])

console.error([data][, ...args])
Prints the message to stderr with new line.Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values.

HelloWorld.js
console.error("User '%s' login failed", "Krishna");

Output
User 'Krishna' login failed

If formatting elements (e.g. %s, %d etc.,) are not found in the first string then util.inspect() is called on each argument and the resulting string values are concatenated.

HelloWorld.js
console.error("User login failed","Krishna","Maximum attempts:",3);

Output
User login failed Krishna Maximum attempts: 3

Previous                                                 Next                                                 Home

No comments:

Post a Comment