Console API

The Console API lets JavaScript send messages to the browser's developer tools, which makes program behavior easier to inspect.

What you will learn

Start with console.log()

const total = 2 + 3;
console.log('total:', total);

Open the browser's developer tools and choose the Console tab to see the message. Logging a label beside the value makes output easier to scan.

Useful methods

console.log()
Shows general information while you inspect a program.
console.warn()
Highlights a condition that deserves attention but is not necessarily fatal.
console.error()
Reports an error or failed operation.
console.time() and console.timeEnd()
Measure the elapsed time between matching labels.

Common mistakes