The Console Panel
🖥️ Lesson 3 — The Console Panel
The Console is the first place to look when something goes wrong. It collects every JavaScript error, warning, and developer log message in one place — and doubles as a live JavaScript interpreter where you can run code directly against the page. Press Ctrl + Shift + K to jump straight to it.
🗺️ The Console Interface
🚦 Message Types at a Glance
console.log() in the page's own JS. Lots of these on a production site means debug logging was left in.console.info(). Framework messages and browser extension output often appear here.console.debug() — enable only when you need it.🔍 Anatomy of an Error Message
Read the stack trace from top to bottom — the top entry is where the exception was thrown. The entries below show the call chain that led there. Click any file:line link to jump directly to the Debugger at that line.
📚 The Console API
.error() does not throw — it only styles the output red.log() for structured data.groupCollapsed() to start collapsed.🔎 Filtering Console Output
On a busy page the Console can fill with hundreds of messages. The text filter box and level toggles keep it manageable.
⚡ Running JavaScript — REPL Shortcuts
The Console input runs JavaScript in the page's own context. Everything on the page is accessible. These built-in shortcuts make common tasks faster:
| Shortcut | What it does | Example result |
|---|---|---|
$('selector') |
Shorthand for document.querySelector() |
$('h1') → <h1> element |
$$('selector') |
Shorthand for querySelectorAll() — returns a real array |
$$('a').length → 42 |
$0 |
The element last selected in the Inspector | $0.textContent → "Hello" |
$1, $2… |
Previously selected elements (history) | $1.className → "card" |
copy(value) |
Copy any value to the clipboard as a string | copy(document.cookie) |
↑ / ↓ arrow |
Cycle through previously run commands (history) | — |
Shift + Enter |
Insert a new line without running — for multi-line snippets | — |
$0.getBoundingClientRect(). You instantly see the element's position and dimensions without writing any code in the page source. This is one of the most practical DevTools techniques.
temp1, temp2, etc. You can then call methods on it, pass it to functions, or copy it without re-running the code that produced it.
✏️ Exercises
-
Audit a real site. Open the Console on any website (
Ctrl + Shift + K). Note how many errors and warnings appear. Click a red error entry and read the stack trace — can you identify what went wrong and where? -
Query the page from the REPL. Type each of these and press Enter:
document.title $$('a').length $$('img').map(i => i.src) -
Use $0. Select any element in the Inspector, switch to the Console, and run:
$0.getBoundingClientRect() $0.className $0.style.border = '2px solid red' -
Time a fetch. Run this in the Console (works on any page that allows fetch):
console.time('test'); await fetch(location.href); console.timeEnd('test'); -
Read a page's performance timing as a table. Run:
console.table(performance.getEntriesByType('navigation'))You'll see load timing data in a formatted table instead of a collapsed object. -
Test filtering. Navigate to a busy site with many console messages. In the filter box, type
-analyticsto hide analytics noise. Then try/error|warn/to show only errors and warnings.
📌 Key Takeaways
- Red errors mean something broke; click the file link to jump straight to the Debugger.
console.table()renders arrays of objects as a table — far easier to read than plainlog().$0refers to the last element selected in the Inspector — interact with it directly in the REPL.$$('selector')returns a real array fromquerySelectorAll()— you can chain.map(),.filter()etc. on it.- Negative filter (
-term) hides noisy messages so you can focus on errors. - Persist Logs keeps messages across page navigations — essential for debugging redirect flows.
- Press Escape from any panel to open the Console drawer — watch Network and run JS simultaneously.