On this page
  1. Debugging, DevTools & Testing
  2. Contents
  3. Browser DevTools Workflow
  4. Console Diagnostics & Breakpoints
  5. Zero-Dependency Assertions & Timing

Debugging, DevTools & Testing

Prev: Progressive Enhancement & Accessibility | Up: tutorials | Next: index
Rel: ES Modules & Error Handling, Reflow, Repaint & Performance, Python Testing and Debugging
Ref: MDN Web Docs — Firefox & Browser DevTools
Tags: #public #web #platform #tutorials #debugging #testing


Contents


Browser DevTools Workflow


Console Diagnostics & Breakpoints

console.table([
  { route: "/items", status: 200, ms: 14 },
  { route: "/health", status: 200, ms: 2 },
]);

// Pause execution when DevTools is open (equivalent to Python's breakpoint())
// debugger;

Zero-Dependency Assertions & Timing

Use console.assert() and performance.now() directly in the browser, or Node's built-in node:test and node:assert/strict for CLI test suites:

function clamp(value, min, max) {
  return Math.max(min, Math.min(value, max));
}

const t0 = performance.now();
console.assert(clamp(15, 0, 10) === 10, "upper clamp failed");
console.assert(clamp(-3, 0, 10) === 0, "lower clamp failed");
console.log(`Assertions finished in ${(performance.now() - t0).toFixed(3)} ms`);

Linked from

Related notes