What is the JavaScript method to output a message to the web console?

The story behind the answer

The JavaScript method used to output a message to the web console is console.log(). It calls the log method on the console object, allowing developers to inspect values, trace program execution, and display diagnostic messages in a browser’s developer tools.

A typical example is console.log("Hello, world!");. JavaScript evaluates the expression inside the parentheses and sends the result to the console rather than placing it visibly in the webpage. Developers can also log variables, arrays, objects, and multiple values, such as console.log("Total:", total).

The console object is supplied by the browser or another JavaScript runtime, not by the core language specification alone. That is why console features can vary slightly between browsers and environments. In Node.js, console.log() also writes output, generally to the process’s standard output stream.

Common mix-ups include console.output, console.write, and console.print. Those names are not the standard browser method for ordinary logging. console.error() and console.warn() are related methods used for error and warning messages, while console.table() formats tabular data.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: