debugger

Pauses execution at this point if a debugger is attached.

Since ES5 Spec ↗

Syntax

debugger;

Examples

function compute(n) {
  const result = n * 2;
  debugger; // execution pauses here when devtools are open
  return result;
}
console.log(compute(21));
Output
42
// With no debugger attached, the statement has no effect
debugger;
console.log("continues normally");
Output
continues normally

Notes

- When developer tools are open, this acts like a programmatically set breakpoint. - With no debugger attached the statement does nothing. - Remove `debugger` statements before shipping production code.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also