Logo

Programming-Idioms

History of Idiom 59 > diff from v37 to v38

Edit summary for version 38 by programming-idioms.org:
[JS] Variable name x. 2 ways => 2 impls

Version 37

2018-05-27, 20:10:10

Version 38

2018-05-27, 20:11:01

Idiom #59 Write to standard error stream

Print the message "x is negative" to standard error (stderr), with integer x value substitution (e.g. "-2 is negative").

Idiom #59 Write to standard error stream

Print the message "x is negative" to standard error (stderr), with integer x value substitution (e.g. "-2 is negative").

Imports
const util = require("util");
Imports
const util = require("util");
Code
console.error(util.format("%d is negative", -2));
// or alternatively:
console.error(-2, " is negative");
Code
console.error(util.format("%d is negative", x));
Doc URL
https://nodejs.org/api/console.html#console_console_error_data_args
Doc URL
https://nodejs.org/api/console.html#console_console_error_data_args