debugger

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

debugger 文は、ブレークポイントの設定などの任意の利用可能なデバッグ機能を呼び出します。デバッグ機能が利用可能ではない場合、この文は効果がありません。

構文

js
debugger;

debugger 文の使用

次の例は、関数が呼び出されたときに、デバッガーを(存在すれば)呼び出すように、 debugger 文が挿入されているコードを示します。

js
function potentiallyBuggyCode() {
  debugger;
  // do potentially buggy stuff to examine, step through, etc.
}

デバッガーが起動していると、実行は debugger 文で停止します。スクリプトのソース内でのブレークポイントと似ています。

開発者ツールをブラウザーに開き、デバッガーパネルで、変数、スコープ、イベントなどを詳しく調べるために、デバッガー文で実行を一時停止している様子。

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-debugger-statement

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
debugger

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報