Console in JavaScript

Last Updated : 11 Jul, 2025

The console object provides access to the browser's debugging console (or terminal in Node.js). It is used to log information, debug code, and interact with the runtime environment during development.

Commonly Used console Methods

Here are the most frequently used methods of the console object:

1. console.log()

The console.log() function logs general information to the console. This is one of the most commonly used methods for debugging in JavaScript.

JavaScript
console.log("Hello, World!");

Output
Hello, World!

2. console.error()

The console .error() function in JavaScript Logs error messages to the console. Typically displayed in red. It is used to display an error message on the console.

JavaScript
console.error("This is an error message.");