Debugging Regular Expressions in Frontend JavaScript
Master JavaScript RegExp flags, avoid catastrophic backtracking, know when regex is the wrong parser, and build a live testing workflow that catches bugs before production.
A practical guide to Chrome DevTools for frontend developers — inspecting elements, debugging JavaScript, analyzing network requests, profiling performance, and workflows that save hours of debugging time.
By codefunc
Browser DevTools are your primary debugging interface. Console.log gets you started; DevTools gets you finished. Inspecting elements, stepping through code, analyzing network requests, profiling performance — these skills separate developers who guess at bugs from developers who diagnose them. Every hour learning DevTools saves ten hours debugging.
Bottom line: Master the Elements panel for DOM/CSS debugging, Console for logging and execution, Sources for breakpoints and stepping, Network for API debugging, and Performance for runtime analysis. Learn the keyboard shortcuts. Use conditional breakpoints. Check the Application tab for storage. DevTools is more powerful than most developers realize.
| Platform | Shortcut |
|---|---|
| Windows/Linux | F12 or Ctrl+Shift+I |
| macOS | Cmd+Option+I |
| Right-click | "Inspect" |
| Action | Windows/Linux | macOS |
|---|---|---|
| Open DevTools | Ctrl+Shift+I |
Cmd+Option+I |
| Open Console | Ctrl+Shift+J |
Cmd+Option+J |
| Open Elements | Ctrl+Shift+C |
Cmd+Shift+C |
| Open Command Menu | Ctrl+Shift+P |
Cmd+Shift+P |
| Search all files | Ctrl+P |
Cmd+P |
The Elements panel shows the live DOM and computed styles.
Ctrl+Shift+CDelete| Method | How |
|---|---|
| Search DOM | Ctrl+F in Elements panel |
| By selector | Search with CSS selector (.class, #id) |
| By XPath | Search with XPath expression |
| By text | Search text content |
The Styles pane shows CSS rules affecting the selected element:
| Task | Method |
|---|---|
| Find why style isn't applied | Check "Computed" tab, look for strikethrough |
| Test color changes | Click color swatch to open picker |
| Debug specificity | Hover over selector to see specificity |
| Copy all styles | Right-click → "Copy" → "Copy styles" |
| Force element state | Right-click → "Force state" (:hover, :focus) |
Click the box model diagram to:
For accessibility testing, check color contrast with the built-in contrast ratio indicator or the Color Contrast Checker.
The Console is for logging, errors, and JavaScript execution.
console.log('Basic output');
console.info('Info message');
console.warn('Warning message');
console.error('Error message');
// Structured data
console.table([{ name: 'Ada', role: 'admin' }, { name: 'Bob', role: 'user' }]);
// Grouped output
console.group('User data');
console.log('Name:', user.name);
console.log('Email:', user.email);
console.groupEnd();
// Timing
console.time('fetch');
await fetchData();
console.timeEnd('fetch'); // fetch: 234ms
// Count calls
console.count('render'); // render: 1, render: 2, ...
// Conditional
console.assert(user.role === 'admin', 'User is not admin');
// Stack trace
console.trace('How did we get here?');
| Utility | Purpose |
|---|---|
$0 |
Currently selected element |
$1, $2... |
Previous selections |
$(selector) |
document.querySelector |
$$(selector) |
document.querySelectorAll |
copy(object) |
Copy to clipboard |
clear() |
Clear console |
keys(obj) |
Object keys |
values(obj) |
Object values |
/error/isource:app.jsPin an expression that updates in real-time:
document.activeElement)The Sources panel is for JavaScript debugging.
| Type | How to set | Use for |
|---|---|---|
| Line breakpoint | Click line number | Pause at specific line |
| Conditional | Right-click line → "Add conditional" | Pause only when condition is true |
| Logpoint | Right-click → "Add logpoint" | Log without pausing |
| DOM breakpoint | Elements → Right-click → "Break on" | Pause when DOM changes |
| XHR breakpoint | Sources → XHR/fetch Breakpoints | Pause on matching requests |
| Event listener | Sources → Event Listener Breakpoints | Pause on events |
| Exception | Toggle in Sources | Pause on errors |
Pause only when a condition is met:
// Right-click line number → "Add conditional breakpoint"
// Enter condition:
user.role === 'admin' && items.length > 10
Log without adding console.log to your code:
// Right-click → "Add logpoint"
// Enter expression:
'User:', user.name, 'Items:', items.length
| Action | Shortcut | Purpose |
|---|---|---|
| Continue | F8 |
Run until next breakpoint |
| Step over | F10 |
Execute line, skip into functions |
| Step into | F11 |
Enter function calls |
| Step out | Shift+F11 |
Finish current function |
Add expressions to watch their values:
When paused:
Source maps connect minified code to original source:
The Network panel shows all HTTP requests.
| Filter | Shows |
|---|---|
Fetch/XHR |
API calls |
JS |
JavaScript files |
CSS |
Stylesheets |
Img |
Images |
Media |
Audio/video |
Font |
Web fonts |
Doc |
HTML documents |
WS |
WebSocket connections |
Click any request to see:
Right-click request → "Copy" → "Copy as cURL" to:
When inspecting JSON responses, the Preview tab formats automatically. For complex responses, copy and paste into JSON Formatter for easier analysis.
Test slow connections:
Enable "Preserve log" to keep requests across page navigation — essential for debugging redirects and form submissions.
The Performance panel records runtime behavior.
Ctrl+E)| Metric | Meaning |
|---|---|
| Scripting (yellow) | JavaScript execution |
| Rendering (purple) | Style/layout calculation |
| Painting (green) | Drawing pixels |
| Loading (blue) | Network requests |
Look for:
The newer "Performance insights" panel provides:
The Application panel manages client-side storage.
| Storage | Location |
|---|---|
| Local Storage | Application → Local Storage |
| Session Storage | Application → Session Storage |
| Cookies | Application → Cookies |
| IndexedDB | Application → IndexedDB |
| Cache Storage | Application → Cache Storage |
Application → Clear storage → select what to clear → "Clear site data"
View registered service workers:
For PWAs, inspect the web app manifest and installation status.
Run audits directly in DevTools:
Enable device toolbar (Ctrl+Shift+M) to:
Debug memory leaks:
Record memory allocations over time to find leaks.
:hover, :focus)| Action | Windows/Linux | macOS |
|---|---|---|
| Open DevTools | F12 |
Cmd+Option+I |
| Toggle device mode | Ctrl+Shift+M |
Cmd+Shift+M |
| Open Command Menu | Ctrl+Shift+P |
Cmd+Shift+P |
| Open file | Ctrl+P |
Cmd+P |
| Search across files | Ctrl+Shift+F |
Cmd+Option+F |
| Go to line | Ctrl+G |
Ctrl+G |
| Toggle console | Esc |
Esc |
| Continue execution | F8 |
F8 |
| Step over | F10 |
F10 |
| Step into | F11 |
F11 |
| Step out | Shift+F11 |
Shift+F11 |
Use these codefunc tools alongside this guide:
DevTools is your debugger, profiler, and network analyzer. Master the keyboard shortcuts — they save minutes every session. Use breakpoints instead of console.log for complex debugging. Check the Network panel first for API issues. Profile before optimizing performance. The Elements panel is for CSS; Sources is for JavaScript; Application is for storage. Learn one panel deeply, then expand to others.
Master JavaScript RegExp flags, avoid catastrophic backtracking, know when regex is the wrong parser, and build a live testing workflow that catches bugs before production.
Use JSONPath to extract fields, filter arrays, and inspect nested API payloads — with practical expressions and a browser tester workflow.
Shrink SVG icons for the web — strip comments and whitespace, choose inline vs data URLs, and know when you still need a full SVGO pipeline.
Find a developer tool