Account
Categories

Debugger Statement(Debugging Tool)


Definition:

This tool helps you easily see where your program has errors.

To do this, you add a debugger statement at the line where you want to check the code.

When you run the program, JavaScript pauses at that line. You can then check the code step by step to see what is happening.

After checking, you can remove the debugger statement. It also acts like a pause, so you can carefully check your code step by step.

Now you will clearly understand with the help of the flowchart.

Start
 |
 v
Step 1: Write your program
 |
 v
Step 2: Choose the line where you want the program to stop
 |
 v
Step 3: Write a debugger on that line
 |
 v
Step 4: Run the program
 |
 v
Step 5: The program stops at the debugger line
 |
 v
Step 6: Check your code step by step
 |
 v
Step 7: Find and fix the mistake
 |
 v
End
  

Example:

let x = 10;
let y = 20;
debugger;  // It pauses the program until it reaches this line.
let sum = x + y;
console.log(sum);

Output: