skip to content

Chrome DevTools

The browser's built-in inspector: DOM and styles, the network panel, performance profiling, and the JavaScript debugger. Interviewers ask because how you move around DevTools shows how you actually diagnose frontend problems.

on this pageshow

explore

questions

18

In Chrome DevTools, how do you pause a script at a chosen line, then step over, into and out of its calls?

level: juniorimportance: must knowfreq 58%

answer

  1. start in the Sources panel
  2. click the line number gutter
  3. pauses before the line runs
  4. over, into and out differ at calls
  5. F10, F11, Shift+F11, then F8

basics

~20 s

Open the Sources panel, click a line number to set a breakpoint, and trigger the code. Execution pauses before that line; Step over runs a call whole, Step into enters it, and Step out finishes the current function.

solid answer

~50 s

I open the file in the **Sources** panel and click the line number, which sets a line-of-code breakpoint, then trigger the code. DevTools pauses *before* that line runs, so an assignment on it has not happened yet. From there I choose the step by what the next call means to the bug. **Step over** (`F10`) runs the call whole and stops on the next statement, unless a breakpoint inside it fires first. **Step into** (`F11`) goes inside the call, and **Step out** (`Shift+F11`) finishes the current function and stops back in its caller. **Resume script execution** (`F8`) runs on to the next breakpoint. If a long stretch is irrelevant, right-clicking a line and choosing **Continue to here** saves the stepping. A `debugger;` statement pauses just like a line breakpoint but lives in the source, so it has to come out before it ships.

code

javascript · 3 lines
javascript
console.log('a');
debugger; // pauses here while DevTools is open, does nothing otherwise
console.log('b');

go deeper

for a junior

Recall the path: Sources panel, click the line number, trigger the code. Then say what each of the three steps does at a function call, and that the pause comes before the line runs.

for a middle

Explain why Step over still executes the call and can still stop inside it. Mention Continue to here and the Breakpoints pane, so stepping does not sound like your only way of moving around.

for a senior

Show that stepping is the last mile, not the method. Say how you reach the right line first, and when a plain line breakpoint is the wrong tool because you do not yet know where the code lives.

for a principal

Treat this as a baseline for the team rather than a debate. The angle worth raising is whether engineers actually use the debugger or default to logging, since that habit shapes how long a production diagnosis takes.

## What a breakpoint does A **breakpoint** tells the browser's debugger to stop running JavaScript at a chosen place, so you can look at the program while it is frozen instead of guessing from its output. The **Sources** panel is where Chrome DevTools shows the page's scripts and the controls for a pause. A **line-of-code breakpoint** is the simplest kind: it stops at one line, and DevTools pauses *before* that line runs. If the line is `const discount = getDiscount(cart);`, then `discount` has not been assigned when you stop there. Breakpoints fire only while DevTools is open. A visitor without DevTools runs the same code at full speed, because the breakpoint lives in your DevTools session and not in the file the server sent. ## Setting one 1. Open DevTools and select the **Sources** panel. 2. Open the file from the tree on the left of the panel. 3. Click the line number. A marker appears in the gutter and the line is listed in the **Breakpoints** pane. 4. Trigger the code, for example by clicking the button that runs it. 5. When execution stops, the line is highlighted and the **Call Stack** and **Scope** panes fill in. Before a pause, both of them just say `Not paused`. ## The stepping controls | Control | Key | What it does | Reach for it when | |---|---|---|---| | **Resume script execution** | `F8` | Runs until the next breakpoint, if any | You have finished looking here | | **Step over** | `F10` | Runs the next call whole, then pauses on the next statement | The call is not related to the problem | | **Step into** | `F11` | Enters the next call and pauses on its first statement | The call may hold the bug | | **Step out** | `Shift+F11` | Runs the rest of the current function and pauses in its caller | You no longer care about this function | | **Step** | `F9` | Moves to the next statement in synchronous order | You want to walk the code as it runs right now | These also have second bindings, such as `Ctrl+'` or `Cmd+'` for Step over. Most people learn the function keys and stop there. ## A worked trace ```js function updateTotal(cart) { const discount = getDiscount(cart); // A render(cart.total - discount); // D } function getDiscount(cart) { const rate = cart.coupon ? 0.1 : 0; // B return cart.total * rate; // C } ``` - Paused on `A`, **Step over** runs all of `getDiscount`, including `B` and `C`, and then pauses on `D`. - Paused on `A`, **Step into** pauses on `B`, inside the called function. - Paused on `B`, **Step out** runs `C`, returns, and pauses back in `updateTotal`. The point people miss is that **Step over does not skip execution**. The function really ran, with all its side effects; you only declined to stop inside it. If a breakpoint sits inside that call, it still fires, and you stop there instead of on the next statement. ## Other ways to pause and move - **The `debugger;` statement** has the same effect as a line-of-code breakpoint, but it is written into the source. It is handy when you are editing the code anyway, and it does nothing when no debugger is attached. The cost is a rebuild to add it and another to remove it. - **Continue to here** appears when you right-click a line while paused. DevTools runs up to that line and pauses, without leaving a permanent breakpoint behind. - **The Breakpoints pane** lists every line-of-code breakpoint, grouped by file. A checkbox disables one without losing it, and right-clicking offers removal or **Reveal location**. - **Deactivate breakpoints** (`Ctrl+F8` or `Cmd+F8`) is a single toggle for all of them at once, for when you need the page to run freely for a while and want your breakpoints back later. ## Mistakes worth avoiding - Expecting the value assigned on the paused line to be visible already. Step once and look again. - Pressing Step over hundreds of times through a loop. A conditional breakpoint gets you to the right iteration directly. - Staying lost inside a library after a wrong Step into. **Step out** brings you back to your own code in one key press. - Committing a stray `debugger;`. Visitors never notice it, which is why it slips through, but it stops every colleague who has DevTools open.

  • What is the difference between F9 and F11 in the Chrome DevTools Sources panel?
    Both enter an ordinary synchronous call. `F11`, **Step into next function call**, also follows a callback the line schedules, such as a `setTimeout` callback, and pauses at its start. `F9`, **Step**, does not make that jump: it moves to the next statement in synchronous order, so you stay with the code that is running right now.
  • Why does Step over sometimes stop inside the function you meant to skip?
    Step over only declines to stop for stepping; any breakpoint inside the call still fires. A line-of-code breakpoint, a conditional breakpoint whose condition is true or a `debugger;` statement inside that function will stop you there first. Disable that breakpoint, or use **Deactivate breakpoints**, if you want the call to run through.
  • When is a debugger statement a better choice than clicking a line number?
    When you are already editing the code, a `debugger;` statement travels with the change, can sit inside your own `if`, and does not depend on a line number that a rebuild might move. Its cost is a rebuild each way and the risk of committing it. For anything already deployed, a DevTools breakpoint needs no source change at all.

  • A breakpoint pauses after its line has run, so the assignment on it is already done.
  • Step over skips the call, so the function's code does not execute.
  • Step out returns to the caller without running the rest of the function.
  • Inspecting a value requires adding console.log calls and reloading the page.
  • A debugger statement left in the code freezes every visitor's browser in production.
open as a page

In the Chrome DevTools Network panel, how do you find one failing API call among hundreds of requests and see what it sent and received?

level: juniorimportance: must knowfreq 58%

basics

~20 s

Open DevTools before triggering the call, click the Fetch/XHR type filter, narrow with terms such as status-code:500 or method:POST, tick Keep log if the page navigates, then click the row and read Headers, Payload and Response.

open as a page

In the Chrome DevTools Sources panel, what changes once a source map loads for a minified bundle, and which code actually runs?

level: juniorimportance: must knowfreq 48%

basics

~20 s

Chrome still runs the minified bundle. A loaded source map only changes what DevTools shows: original files appear in Sources, and breakpoints, errors, logs and Call Stack frames are translated to original files and lines.

open as a page

In the Chrome DevTools Timing tab for a request, what does each main phase mean and what does a long one point to?

level: middleimportance: must knowfreq 52%

basics

~20 s

Queueing and Stalled mean the browser held the request back; DNS lookup, Initial connection and SSL mean connection setup; Waiting for server response means server time plus a round trip; Content download means reading the body.

open as a page

In Chrome DevTools, how do you find the code behind a checkout button that sometimes does nothing, in a large bundled application you did not write?

level: seniorimportance: must knowfreq 55%

basics

~20 s

Do not read the bundle: make the symptom pause you. Use an Event Listener Breakpoint on click, an XHR/fetch breakpoint on the request URL, a DOM change breakpoint on the button and Pause on caught exceptions, then read the Call Stack.

open as a page

In Chrome DevTools, a production stack frame still reads `checkout.4be1.js:1:90412` in the Console and Sources; how do you work out why no source map applied?

level: seniorimportance: must knowfreq 45%

basics

~20 s

Open the deployed file in Sources and read its notice: failed to load, skipped, or loaded. No notice points to the setting or a missing reference, where Add source map attaches one by URL. Wrong lines mean another build's map.

open as a page

In Chrome DevTools, a bug hits only the fifth item of a list: would you use a conditional breakpoint or a logpoint, and why?

level: middleimportance: should knowfreq 52%

basics

~20 s

Use a conditional breakpoint to pause only when an expression such as index === 4 is true. Use a logpoint to print values on every hit without pausing, when you need the sequence or a pause would hide the bug.

open as a page

In Chrome DevTools, what do Pause on uncaught exceptions and Pause on caught exceptions each stop on, and when do you need the second?

level: middleimportance: should knowfreq 42%

basics

~20 s

Pause on uncaught exceptions stops on a throw no handler will catch; Pause on caught exceptions stops on a throw a handler will absorb. You need the second when something swallows an error and the feature fails silently.

open as a page

While paused in Chrome DevTools, how do you test a theory about a wrong value without reloading the page and reproducing the bug again?

level: middleimportance: should knowfreq 38%

basics

~20 s

Edit the value in the Scope pane, track derived expressions in Watch, run code in the Console against the selected frame, then use Restart frame to run the function again. Restarting does not undo what the function already changed.

open as a page

In Chrome DevTools, what sensitive data travels with an exported HAR file versus a request copied as cURL or fetch?

level: middleimportance: should knowfreq 33%

basics

~20 s

A default HAR export is sanitized: Cookie, Set-Cookie and Authorization headers are removed, yet URLs, bodies and custom token headers stay. Copy as cURL is not sanitized and carries the session cookie and Authorization in clear text.

open as a page

In the Chrome DevTools Console, how do you inspect a button's listeners and events, and why can't those helpers ship in a page script?

level: middleimportance: should knowfreq 30%

basics

~10 s

Select the button in Elements, then use getEventListeners($0) for its registered listeners and monitorEvents($0, 'mouse') to log its events. These Console utilities work only from the Console, so a page script calling them fails.

open as a page

In Chrome DevTools, what does putting a script on the ignore list change about stepping, exceptions and stack traces, and what does it leave alone?

level: middleimportance: should knowfreq 33%

basics

~10 s

An ignored script still runs unchanged. The debugger skips stepping through it and won't stop on its exceptions, and its frames are hidden from the Call Stack pane until you check Show ignore-listed frames.

open as a page

Using Chrome DevTools, how do you track down an API call that fails only for returning users with cached assets and never reproduces with your DevTools open?

level: seniorimportance: should knowfreq 37%

basics

~20 s

Disable cache probably hides the failure: untick it, reload as a returning visitor, read each script's source in the Size column, follow the failing call's Initiator tab back to that script, and compare its call with the current build.

open as a page

Using the Chrome DevTools Network panel, how do you narrow down why an API call is slow for some users but fast on your machine?

level: seniorimportance: should knowfreq 46%

basics

~20 s

Get a sanitized HAR from an affected user, import it, and compare that call's Timing tab with yours: the phase that differs names the layer. Then test the theory locally with throttling, knowing it only approximates their network.

open as a page

In Chrome DevTools, how do you try a one-line fix for a production-only bug in a minified bundle when you have no local build?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Use local overrides: choose a folder, use Override content on the deployed bundle, edit, save and reload, and DevTools serves your copy. Source-mapped originals can't be overridden, so the edit goes into the minified file.

open as a page

In Chrome DevTools, how do you test a page with one script missing or an API returning different data, without changing the server?

level: middleimportance: nice to knowfreq 30%

basics

~20 s

Block the script by right-clicking its row and choosing Block requests, which adds a rule in the Request conditions drawer. Change an API's response with Override content or Override headers, which serve your local edits from a selected folder.

open as a page

In Chrome DevTools, when do you pin a Console live expression rather than save a Sources snippet, and what risk comes with each?

level: middleimportance: nice to knowfreq 20%

basics

~20 s

Pin a live expression to watch a value that keeps changing, because DevTools re-evaluates it about every 250 ms. Save a snippet for a script you rerun on demand. Live expressions repeat side effects; snippets are local and unsynced.

open as a page

In Chrome DevTools, paused in a promise callback holding a wrong total, how do you find what scheduled it and step across that async hop?

level: seniorimportance: nice to knowfreq 33%

basics

~20 s

The Call Stack pane adds async sections below the running frames, showing the code that scheduled this callback; those frames give locations, not live variables. Step into (F11) follows a callback the current line schedules, while Step (F9) stays with synchronous code.

open as a page