What is the Console API?

The Console API helps you inspect JavaScript while you are building a page. It writes information to the browser's developer tools instead of changing the page for visitors.

What you will learn

Open the Console

Open the browser's developer tools with the menu or with Ctrl+Shift+I, then choose the Console tab. You can also right-click a page and choose Inspect. The exact menu label may differ between browsers.

Try console.log()

const userName = 'Yugien';
console.log('userName:', userName);

Run this code in the Console. The label makes the output easier to scan when several values are logged.

Read errors carefully

notDefinedFunction();

The Console reports that the function is not defined and points to a source location. Read the first useful error and its location before changing unrelated code.

Common mistakes