The Console

The Console isn't just for running code—it's a window into what your page is thinking. Learn to read its messages like a conversation.

Mental Model

Think of the Console as listening to a conversation between the browser and your code. Messages appear when something happens: code runs, errors occur, or you explicitly ask elements to "speak."

Opening the Console

Three ways to access the Console in Firefox:

The Split View

The Esc shortcut is powerful—it lets you see the Console while staying in the Inspector. This is the "both tools at once" mode you'll use most often. Press Esc again to hide it.

Reading Message Types

The Console shows different types of messages. Learn to recognize them at a glance:

Console
log Button clicked
info Page loaded in 234ms
warn Image has no alt attribute
error Cannot read properties of null (reading 'classList')

What each type means:

Your First Console Commands

Open the Console Playground and try these commands. Type each one and press Enter.

Math works

// The Console is a calculator
2 + 2
→ 4

100 / 3
→ 33.333...

Finding elements

// Find the heading
document.querySelector('h1')
→ <h1>Console Playground</h1>

// Find the counter display
document.querySelector('#counter')
→ <span id="counter">0</span>

// Find the color box
document.querySelector('.color-box')
→ <div class="color-box">...</div>

Changing things

// Change the heading text
document.querySelector('h1').textContent = 'Hello World'
→ "Hello World"

// Change the heading color
document.querySelector('h1').style.color = 'tomato'
→ "tomato"
This is real JavaScript

Every command you type in the Console is actual JavaScript running on the page. When you build a theme toggle in Week 1, you'll write the same querySelector and classList commands in a file instead of typing them manually.

Making Elements Talk

console.log() is how you make your code talk. When debugging, insert it anywhere to see what's happening:

const button = document.querySelector('#primary-btn');

// Did we find it?
console.log('Found button:', button);

// What classes does it have?
console.log('Classes:', button.classList);

button.addEventListener('click', () => {
  console.log('Button was clicked!');
  button.classList.toggle('active');
  console.log('Classes now:', button.classList);
});
Console
Found button: <button id="primary-btn">...</button>
Classes: DOMTokenList ["btn", "primary"]
— user clicks —
Button was clicked!
Classes now: DOMTokenList ["btn", "primary", "active"]

Filtering Messages

When the Console gets noisy, filter it. In Firefox, use the filter buttons at the top of the Console panel:

You can also type in the filter box to search for specific text.

Clearing the Console

Two ways to clear all messages:

Practice: Console Exploration
  1. Open the Console Playground
  2. Open DevTools (Cmd+Option+K)
  3. Find the #counter element using document.querySelector('#counter')
  4. Read its current value: add .textContent to your query
  5. Change it: document.querySelector('#counter').textContent = '999'
  6. Click the + button on the page — what happens to your value?