console.error()

Outputs an error message to the console.

Since ES5 Spec ↗

Syntax

console.error(...data)

Returns

undefined — Returns `undefined`.

Examples

console.error("Something failed");
Output
Something failed
console.error("Code %d: %s", 500, "Server Error");
Output
Code 500: Server Error
console.error(new Error("boom"));
Output
Error: boom

Notes

- Typically rendered in red and writes to stderr in Node.js. - Supports printf-style format specifiers like `%s`, `%d`, `%o`. - Does not throw or stop execution; it only logs.

Browser & runtime support

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

See also