Skip to content
SoftwareSolutions.net
Beginner

How to Debug JavaScript in the Browser Console

Use the console, breakpoints and the network panel to find errors, inspect values and confirm that code runs as intended.

Last updated 2026-11-25

Open the console and read errors

Open developer tools in your browser and select the console. Errors appear in red with a file name and line number. Click the link to jump to the source. Warnings in yellow often point to deprecated features or problems that will become errors later, so review them too.

Log values and check assumptions

Use console.log to print variables and confirm what they contain at a given point. Use console.table for arrays of objects, which makes data easier to scan. Remove logs once you are finished, because noisy output hides the messages that matter.

Use breakpoints for step-by-step control

Click a line number in the Sources panel to set a breakpoint. When the code pauses, inspect variables in the scope panel and step through each line with the step controls. Conditional breakpoints pause only when a condition is true, which helps with bugs that happen in long loops.

Inspect network requests

The network panel shows each request, its status code, headers and response. Many front-end bugs come from failed requests, wrong data or missing authentication. Filter by request type and check the response body before changing your code.

Frequently asked questions

Why does my breakpoint not stop?
The loaded file may differ from the source you are editing, often because of caching or a build step. Reload the page with cache disabled and check that source maps are working.
Should I use alert() for debugging?
Avoid it. Alerts block the page and interrupt testing. Console logs and breakpoints give more information without stopping the browser.
Can I debug on a phone?
Yes. Mobile browsers can connect to desktop developer tools for remote debugging, which is useful when a bug only appears on a device.