console.warn()

Outputs a warning message to the console.

Since ES5 Spec ↗

Syntax

console.warn(...data)

Returns

undefined — Returns `undefined`.

Examples

console.warn("Deprecated API used");
Output
Deprecated API used
console.warn("Retry %d of %d", 2, 3);
Output
Retry 2 of 3

Notes

- Typically rendered in yellow with a warning icon in browsers. - Writes to stderr in Node.js. - Supports printf-style format specifiers.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also