How to Debug Javascript
Determine if debugger; is the correct tool for this situation., Before the problem area, enter the statement: debugger; , Open your browser's developer tools by right clicking and selecting inspect element., Once inside of developer tools, run your...
Step-by-Step Guide
-
Step 1: Determine if debugger; is the correct tool for this situation.
Ask yourself:
Do I need to look at this in great detail? Do I want to know the values, and the path the program is taking? Can I effectively test this through the developer window? -
Step 2: Before the problem area
, This will be browser specific, but they should all work very similarly. , This time it will stop at the debugger; statement. ,, You may have to restart your program to trigger the debugger; again. , -
Step 3: enter the statement: debugger;
-
Step 4: Open your browser's developer tools by right clicking and selecting inspect element.
-
Step 5: Once inside of developer tools
-
Step 6: run your code again.
-
Step 7: Step through your program
-
Step 8: line-by-line
-
Step 9: by pressing F10.
-
Step 10: Repeat the process as necessary.
-
Step 11: Once you've used the debugger to solve the problem
-
Step 12: be sure to remove the statement when you're done.
Detailed Guide
Ask yourself:
Do I need to look at this in great detail? Do I want to know the values, and the path the program is taking? Can I effectively test this through the developer window?
, This will be browser specific, but they should all work very similarly. , This time it will stop at the debugger; statement. ,, You may have to restart your program to trigger the debugger; again. ,
About the Author
Sarah Scott
A passionate writer with expertise in practical skills topics. Loves sharing practical knowledge.
Rate This Guide
How helpful was this guide? Click to rate: