Skip to content

debugger

In JavaScript, the debugger keyword is a statement that pauses execution at that point when a debugger is attached, and has no effect when none is. It works like a breakpoint written into the source code.

ECMA-262 leaves the exact behavior to the engine. Browsers pause on the statement while their developer tools are open. Node.js pauses on it when a script runs under node inspect or with the --inspect flag and a connected debugging client. Without a debugger, the engine skips the statement and the code runs as usual.

The statement takes no operands and ends with a semicolon, like break or continue without a label. Linters usually flag leftover debugger statements, because shipping one to production can pause a user’s session when their developer tools happen to be open.

JavaScript debugger Keyword Examples

A debugger statement marks a spot where an attached debugger pauses:

Language: JavaScript
> function applyDiscount(price, rate) {
…   debugger;
…   return price * (1 - rate);
… }
undefined
> applyDiscount(80, 0.25)
60

With no debugger attached, the REPL runs straight past the statement and returns the result. With a debugger attached, execution would stop before the return line, so price and rate could be inspected.

JavaScript debugger Keyword Use Cases

  • Pausing at a specific line without setting a breakpoint in the debugger’s interface
  • Stopping inside code that’s hard to reach from the developer tools, such as generated or bundled code
  • Inspecting variables in a callback or event handler at the moment it runs
  • Pausing only when a condition holds, by placing debugger inside an if block

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Nov. 3, 2026